1. 18 Jun, 2011 4 commits
  2. 09 Jun, 2011 1 commit
    • Ian Lynagh's avatar
      Refactor SrcLoc and SrcSpan · b2bd63f9
      Ian Lynagh authored
      The "Unhelpful" cases are now in a separate type. This allows us to
      improve various things, e.g.:
      * Most of the panic's in SrcLoc are now gone
      * The Lexer now works with RealSrcSpans rather than SrcSpans, i.e. it
        knows that it has real locations and thus can assume that the line
        number etc really exists
      * Some of the more suspicious cases are no longer necessary, e.g.
        we no longer need this case in advanceSrcLoc:
            advanceSrcLoc loc _ = loc -- Better than nothing
      
      More improvements can probably be made, e.g. tick locations can
      probably use RealSrcSpans too.
      b2bd63f9
  3. 03 Jun, 2011 2 commits
  4. 26 May, 2011 1 commit
  5. 20 May, 2011 1 commit
  6. 26 Apr, 2011 1 commit
  7. 19 Apr, 2011 1 commit
    • Simon Peyton Jones's avatar
      This BIG PATCH contains most of the work for the New Coercion Representation · fdf86568
      Simon Peyton Jones authored
      See the paper "Practical aspects of evidence based compilation in System FC"
      
      * Coercion becomes a data type, distinct from Type
      
      * Coercions become value-level things, rather than type-level things,
        (although the value is zero bits wide, like the State token)
        A consequence is that a coerion abstraction increases the arity by 1
        (just like a dictionary abstraction)
      
      * There is a new constructor in CoreExpr, namely Coercion, to inject
        coercions into terms
      fdf86568
  8. 12 Apr, 2011 1 commit
    • Simon Marlow's avatar
      Change the way module initialisation is done (#3252, #4417) · a52ff761
      Simon Marlow authored
      Previously the code generator generated small code fragments labelled
      with __stginit_M for each module M, and these performed whatever
      initialisation was necessary for that module and recursively invoked
      the initialisation functions for imported modules.  This appraoch had
      drawbacks:
      
       - FFI users had to call hs_add_root() to ensure the correct
         initialisation routines were called.  This is a non-standard,
         and ugly, API.
      
       - unless we were using -split-objs, the __stginit dependencies would
         entail linking the whole transitive closure of modules imported,
         whether they were actually used or not.  In an extreme case (#4387,
         #4417), a module from GHC might be imported for use in Template
         Haskell or an annotation, and that would force the whole of GHC to
         be needlessly linked into the final executable.
      
      So now instead we do our initialisation with C functions marked with
      __attribute__((constructor)), which are automatically invoked at
      program startup time (or DSO load-time).  The C initialisers are
      emitted into the stub.c file.  This means that every time we compile
      with -prof or -hpc, we now get a stub file, but thanks to #3687 that
      is now invisible to the user.
      
      There are some refactorings in the RTS (particularly for HPC) to
      handle the fact that initialisers now get run earlier than they did
      before.
      
      The __stginit symbols are still generated, and the hs_add_root()
      function still exists (but does nothing), for backwards compatibility.
      a52ff761
  9. 05 Apr, 2011 1 commit
    • Simon Marlow's avatar
      Merge _stub.o files into the main .o file (Fixes #3687 and #706) · 7b0ff179
      Simon Marlow authored
      Now GHC still generates the _stub.c files, but the object file is
      automatically merged into the main .o file for a module.  This means
      that build systems (including GHC's own) no longer need to worry about
      looking for _stub.o files and including them when linking.
      
      I had to do lots of refactoring in DriverPipeline to make this work;
      now there's a monad to carry around all the information, and
      everything is a lot tidier.
      
      The _stub.c is now created as a temporary file and removed after
      compilation (unless the -keep-tmp-files flag is on).
      7b0ff179
  10. 20 Feb, 2011 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Added a VECTORISE pragma · f2aaae97
      chak@cse.unsw.edu.au. authored
      - Added a pragma {-# VECTORISE var = exp #-} that prevents
        the vectoriser from vectorising the definition of 'var'.
        Instead it uses the binding '$v_var = exp' to vectorise
        'var'.  The vectoriser checks that the Core type of 'exp'
        matches the vectorised Core type of 'var'.  (It would be
        quite complicated to perform that check in the type checker
        as the vectorisation of a type needs the state of the VM
        monad.)
      - Added parts of a related VECTORISE SCALAR pragma
      - Documented -ddump-vect
      - Added -ddump-vt-trace
      - Some clean up
      f2aaae97
  11. 12 Jan, 2011 1 commit
    • simonpj@microsoft.com's avatar
      Major refactoring of the type inference engine · 27310213
      simonpj@microsoft.com authored
      This patch embodies many, many changes to the contraint solver, which
      make it simpler, more robust, and more beautiful.  But it has taken
      me ages to get right. The forcing issue was some obscure programs
      involving recursive dictionaries, but these eventually led to a
      massive refactoring sweep.
      
      Main changes are:
       * No more "frozen errors" in the monad.  Instead "insoluble
         constraints" are now part of the WantedConstraints type.
      
       * The WantedConstraint type is a product of bags, instead of (as
         before) a bag of sums.  This eliminates a good deal of tagging and
         untagging.
      
       * This same WantedConstraints data type is used
           - As the way that constraints are gathered
           - As a field of an implication constraint
           - As both argument and result of solveWanted
           - As the argument to reportUnsolved
      
       * We do not generate any evidence for Derived constraints. They are
         purely there to allow "impovement" by unifying unification
         variables.
      
       * In consequence, nothing is ever *rewritten* by a Derived
         constraint.  This removes, by construction, all the horrible
         potential recursive-dictionary loops that were making us tear our
         hair out.  No more isGoodRecEv search either. Hurrah!
      
       * We add the superclass Derived constraints during canonicalisation,
         after checking for duplicates.  So fewer superclass constraints
         are generated than before.
      
       * Skolem tc-tyvars no longer carry SkolemInfo.  Instead, the
         SkolemInfo lives in the GivenLoc of the Implication, where it
         can be tidied, zonked, and substituted nicely.  This alone is
         a major improvement.
      
       * Tidying is improved, so that we tend to get t1, t2, t3, rather
         than t1, t11, t111, etc
      
         Moreover, unification variables are always printed with a digit
         (thus a0, a1, etc), so that plain 'a' is available for a skolem
         arising from a type signature etc. In this way,
           (a) We quietly say which variables are unification variables,
               for those who know and care
           (b) Types tend to get printed as the user expects.  If he writes
                   f :: a -> a
                   f = ...blah...
               then types involving 'a' get printed with 'a', rather than
               some tidied variant.
      
       * There are significant improvements in error messages, notably
         in the "Cannot deduce X from Y" messages.
      27310213
  12. 22 Dec, 2010 1 commit
  13. 15 Nov, 2010 1 commit
    • pepeiborra@gmail.com's avatar
      Fix bug #3165 (:history throws irrefutable pattern failed) · add9b7f1
      pepeiborra@gmail.com authored
      I ran across this bug and took the time to fix it, closing
      a long time due TODO in InteractiveEval.hs
      
      Instead of looking around to find the enclosing declaration
      of a tick, this patch makes use of the information already collected during the
      coverage desugaring phase
      add9b7f1
  14. 27 Oct, 2010 1 commit
    • Simon Marlow's avatar
      Refactoring and tidyup of HscMain and related things (also fix #1666) · 94bf0d36
      Simon Marlow authored
      While trying to fix #1666 (-Werror aborts too early) I decided to some
      tidyup in GHC/DriverPipeline/HscMain.
      
       - The GhcMonad overloading is gone from DriverPipeline and HscMain
         now.  GhcMonad is now defined in a module of its own, and only
         used in the top-level GHC layer.  DriverPipeline and HscMain
         use the plain IO monad and take HscEnv as an argument.
      
       - WarnLogMonad is gone.  printExceptionAndWarnings is now called
         printException (the old name is deprecated).  Session no longer
         contains warnings.
      
       - HscMain has its own little monad that collects warnings, and also
         plumbs HscEnv around.  The idea here is that warnings are collected
         while we're in HscMain, but on exit from HscMain (any function) we
         check for warnings and either print them (via log_action, so IDEs
         can still override the printing), or turn them into an error if
         -Werror is on.
      
       - GhcApiCallbacks is gone, along with GHC.loadWithLogger.  Thomas
         Schilling told me he wasn't using these, and I don't see a good
         reason to have them.
      
       - there's a new pure API to the parser (suggestion from Neil Mitchell):
            parser :: String
                   -> DynFlags
                   -> FilePath
                   -> Either ErrorMessages (WarningMessages, 
                                            Located (HsModule RdrName))
      94bf0d36
  15. 19 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Clean up the debugger code · a40f2735
      simonpj@microsoft.com authored
      In particular there is much less fiddly skolemisation now
      Things are not *quite* right (break001 and 006 still fail), 
      but they are *much* better than before.
      a40f2735
  16. 13 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Remove GHC.extendGlobalRdrScope, GHC.extendGlobalTypeScope · 762c2432
      simonpj@microsoft.com authored
      These functions were added by
      
         Tue Apr 18 03:36:06 BST 2006  Lemmih <lemmih@gmail.com>
         * Make the initial rdr and type scope available in the ghc-api
      
      The are extremely dubious, because they extend the Rdr and Type
      env for every compilation.  The right thing to do is to use
      the InteractiveContext for temporary extensions.
      
      So far as we know, no one uses them.  And if they are being used
      it's probably a mistake.  So we're backing them out.
      762c2432
  17. 14 Sep, 2010 1 commit
    • Ian Lynagh's avatar
      Remove (most of) the FiniteMap wrapper · e95ee1f7
      Ian Lynagh authored
      We still have
          insertList, insertListWith, deleteList
      which aren't in Data.Map, and
          foldRightWithKey
      which works around the fold(r)WithKey addition and deprecation.
      e95ee1f7
  18. 13 Sep, 2010 1 commit
  19. 09 Jul, 2010 1 commit
  20. 25 Jun, 2010 1 commit
  21. 20 Mar, 2010 1 commit
  22. 07 Dec, 2009 1 commit
  23. 17 Oct, 2009 1 commit
  24. 18 Aug, 2009 1 commit
    • Thomas Schilling's avatar
      Remove the lock around NameCache for readBinIface. · cadba810
      Thomas Schilling authored
      Turns out using atomic update instead of a full-blown lock was easier
      than I thought.  It should also be safe in the case where we
      concurrently read the same interface file.  Whichever thread loses the
      race will simply find that all of the names are already defined and
      will have no effect on the name cache.
      cadba810
  25. 17 Aug, 2009 1 commit
    • Thomas Schilling's avatar
      Make access to NameCache atomic. Sometimes needs a lock. · 9f68c348
      Thomas Schilling authored
      'readBinIface' updates the name cache in a way that is hard to use
      with atomicModifyIORef, so this patch introduces a lock for this case.
      All other updates use atomicModifyIORef.
      
      Having a single lock is quite pessimistic, so it remains to be seen
      whether this will become a problem.  In principle we only need to make
      sure that we do not load the same file concurrently (or that it's
      idempotent).  In practice we also need to ensure that concurrent reads
      do not cancel each other out (since the new NameCache may be based on
      an outdated version).
      9f68c348
  26. 07 Jul, 2009 1 commit
  27. 28 May, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Improve printing of Orig RdrNames · 30ced404
      simonpj@microsoft.com authored
      In Tempate Haskell -ddump-splices, the "after" expression is populated 
      with RdrNames, many of which are Orig things.  We used to print these
      fully-qualified, but that's a bit heavy.
      
      This patch refactors the code a bit so that the same print-unqualified
      mechanism we use for Names also works for RdrNames.  Lots of comments
      too, because it took me a while to figure out how it all worked again.
      30ced404
  28. 13 Mar, 2009 1 commit
  29. 06 Feb, 2009 1 commit
    • Simon Marlow's avatar
      Improvements to the "can't find module" error message (#2980) · 305b24aa
      Simon Marlow authored
      If the module was found in multiple hidden packages, we list them all.
      
      Could not find module `Data.Generics':
        it is a member of the hidden package `base-3.0.3.0'
        it is a member of the hidden package `syb'
        Use -v to see a list of the files searched for.
      305b24aa
  30. 27 Jan, 2009 1 commit
  31. 02 Jan, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Make record selectors into ordinary functions · 9ffadf21
      simonpj@microsoft.com authored
      This biggish patch addresses Trac #2670.  The main effect is to make
      record selectors into ordinary functions, whose unfoldings appear in
      interface files, in contrast to their previous existence as magic
      "implicit Ids".  This means that the usual machinery of optimisation,
      analysis, and inlining applies to them, which was failing before when
      the selector was somewhat complicated.  (Which it can be when
      strictness annotations, unboxing annotations, and GADTs are involved.)
      
      The change involves the following points
      
      * Changes in Var.lhs to the representation of Var.  Now a LocalId can
        have an IdDetails as well as a GlobalId.  In particular, the
        information that an Id is a record selector is kept in the
        IdDetails.  While compiling the current module, the record selector
        *must* be a LocalId, so that it participates properly in compilation
        (free variables etc).
      
        This led me to change the (hidden) representation of Var, so that there
        is now only one constructor for Id, not two.
      
      * The IdDetails is persisted into interface files, so that an
        importing module can see which Ids are records selectors.
      
      * In TcTyClDecls, we generate the record-selector bindings in renamed,
        but not typechecked form.  In this way, we can get the typechecker
        to add all the types and so on, which is jolly helpful especially
        when GADTs or type families are involved.  Just like derived
        instance declarations.
      
        This is the big new chunk of 180 lines of code (much of which is
        commentary).  A call to the same function, mkAuxBinds, is needed in
        TcInstDcls for associated types.
      
      * The typechecker therefore has to pin the correct IdDetails on to 
        the record selector, when it typechecks it.  There was a neat way
        to do this, by adding a new sort of signature to HsBinds.Sig, namely
        IdSig.  This contains an Id (with the correct Name, Type, and IdDetails);
        the type checker uses it as the binder for the final binding.  This
        worked out rather easily.
      
      * Record selectors are no longer "implicit ids", which entails changes to
           IfaceSyn.ifaceDeclSubBndrs
           HscTypes.implicitTyThings
           TidyPgm.getImplicitBinds
        (These three functions must agree.)
      
      * MkId.mkRecordSelectorId is deleted entirely, some 300+ lines (incl
        comments) of very error prone code.  Happy days.
      
      * A TyCon no longer contains the list of record selectors: 
        algTcSelIds is gone
      
      The renamer is unaffected, including the way that import and export of
      record selectors is handled.
      
      Other small things
      
      * IfaceSyn.ifaceDeclSubBndrs had a fragile test for whether a data
        constructor had a wrapper.  I've replaced that with an explicit flag
        in the interface file. More robust I hope.
      
      * I renamed isIdVar to isId, which touched a few otherwise-unrelated files.
      
      9ffadf21
  32. 02 Dec, 2008 2 commits
  33. 28 Nov, 2008 2 commits
    • Thomas Schilling's avatar
    • Thomas Schilling's avatar
      Use a per-session data structure for callbacks. Make 'WarnErrLogger' · 9a4607c3
      Thomas Schilling authored
      part of it.
      
      Part of the GHC API essentially represents a compilation framework.
      The difference of a *framework* as opposed to a *library* is that the
      overall structure of the functionality is pre-defined but certain
      details can be customised via callbacks.  (Also known as the Hollywood
      Principle: "Don't call us, we'll call you.")
      
      This patch introduces a per-session data structure that contains all
      the callbacks instead of adding lots of small function arguments
      whenever we want to give the user more control over certain parts of
      the API.  This should also help with future changes: Adding a new
      callback doesn't break old code since code that doesn't know about the
      new callback will use the (hopefully sane) default implementation.
      
      Overall, however, we should try and keep the number of callbacks small
      and well-defined (and provide useful defaults) and use simple library
      routines for the rest.
      9a4607c3
  34. 26 Nov, 2008 1 commit
    • Thomas Schilling's avatar
      Force recompilation of BCOs when they were compiled in HscNothing mode. · 5e0453ca
      Thomas Schilling authored
      Previously, loading a set of modules in HscNothing mode and then
      switching to HscInterpreted could lead to crashes since modules
      compiled with HscNothing were thought to be valid bytecode objects.
      
      This patch forces recompilation in these cases, hence switching between
      HscNothing and HscInterpreted should be safe now.
      5e0453ca