1. 04 May, 2011 1 commit
    • Simon Peyton Jones's avatar
      Final batch of monad-comprehension stuff · 3bb700d5
      Simon Peyton Jones authored
      * Do-notation in arrows is marked with HsStmtContext = ArrowExpr
      * tcMDoStmt (which was only used for arrows) is moved
        to TcArrows, and renamed tcArrDoStmt
      * Improved documentation in the user manual
      * Lots of other minor changes
      3bb700d5
  2. 07 Apr, 2011 1 commit
    • Thomas Schilling's avatar
      Start support for coloured SDoc output. · 4e6bac1e
      Thomas Schilling authored
      The SDoc type now passes around an abstract SDocContext rather than
      just a PprStyle which required touching a few more files.  This should
      also make it easier to integrate DynFlags passing, so that we can get
      rid of global variables.
      4e6bac1e
  3. 06 Apr, 2011 1 commit
  4. 05 Apr, 2011 1 commit
  5. 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
  6. 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
  7. 22 Dec, 2010 1 commit
  8. 15 Dec, 2010 1 commit
  9. 02 Dec, 2010 1 commit
  10. 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
  11. 23 Oct, 2010 1 commit
  12. 21 Oct, 2010 2 commits
  13. 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
  14. 08 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Beautiful new approach to the skolem-escape check and untouchable · debb7b80
      simonpj@microsoft.com authored
      Instead of keeping a *set* of untouchable variables in each
      implication contraints, we keep a *range* of uniques for the
      *touchable* variables of an implication.  This are precisely
      the ones we would call the "existentials" if we were French.
      
      It turns out that the code is more efficient, and vastly easier
      to get right, than the set-based approach.
      
      Fixes Trac #4355 among others
      debb7b80
  15. 07 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Implement auto-specialisation of imported Ids · 92267aa2
      simonpj@microsoft.com authored
      This big-ish patch arranges that if an Id 'f' is 
        * Type-class overloaded 
             f :: Ord a => [a] -> [a]
        * Defined with an INLINABLE pragma
             {-# INLINABLE f #-}
        * Exported from its defining module 'D'
      
      then in any module 'U' that imports D
      
      1. Any call of 'f' at a fixed type will generate 
         (a) a specialised version of f in U
         (b) a RULE that rewrites unspecialised calls to the
             specialised on
      
        e.g. if the call is (f Int dOrdInt xs) then the 
        specialiser will generate
           $sfInt :: [Int] -> [Int]
           $sfInt = <code for f, imported from D, specialised>
           {-# RULE forall d.  f Int d = $sfInt #-}
      
      2. In addition, you can give an explicit {-# SPECIALISE -#}
         pragma for the imported Id
           {-# SPECIALISE f :: [Bool] -> [Bool] #-}
         This too generates a local specialised definition, 
         and the corresponding RULE 
      
      The new RULES are exported from module 'U', so that any module
      importing U will see the specialised versions of 'f', and will
      not re-specialise them.
      
      There's a flag -fwarn-auto-orphan that warns you if the auto-generated
      RULES are orphan rules. It's not in -Wall, mainly to avoid lots of
      error messages with existing packages.
      
      Main implementation changes
      
       - A new flag on a CoreRule to say if it was auto-generated.
         This is persisted across interface files, so there's a small
         change in interface file format.
      
       - Quite a bit of fiddling with plumbing, to get the 
         {-# SPECIALISE #-} pragmas for imported Ids.  In particular, a
         new field tgc_imp_specs in TcGblEnv, to keep the specialise
         pragmas for imported Ids between the typechecker and the desugarer.
      
       - Some new code (although surprisingly little) in Specialise,
         to deal with calls of imported Ids
      92267aa2
  16. 06 Oct, 2010 1 commit
  17. 19 Sep, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Add a flag -fwarn-missing-local-sigs, and improve -fwarn-mising-signatures · e8fa04cf
      simonpj@microsoft.com authored
      The new flag prints out a warning if you have a local,
      polymorphic binding that lacks a type signature. It's meant
      to help with the transition to the new typechecker, which
      discourages local let-generalisation.
      
      At the same time I moved the missing-signature code to TcHsSyn,
      where it takes place as part of zonking.  That way the 
      types are reported after all typechecking is complete,
      thereby fixing Trac #3696.  (It's even more important for
      local bindings, which is why I made the change.)
      e8fa04cf
  18. 18 Sep, 2010 1 commit
  19. 13 Sep, 2010 1 commit
  20. 24 Jul, 2010 3 commits
  21. 20 Mar, 2010 1 commit
  22. 30 Nov, 2009 1 commit
  23. 05 Nov, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3640, plus associated refactoring · df8b00e0
      simonpj@microsoft.com authored
      In fixing this bug (to do with record puns), I had the usual rush of
      blood to the head, and I did quite a bit of refactoring in the way
      that duplicate/shadowed names are reported.
      
      I think the result is shorter as well as clearer.
      
      In one place I found it convenient for the renamer to use the ErrCtxt
      carried in the monad.  (The renamer used not to have such a context,
      but years ago the typechecker and renamer monads became one, so now it
      does.)   So now it's availble if you want it in future.
      df8b00e0
  24. 15 Sep, 2009 1 commit
  25. 26 Aug, 2009 1 commit
  26. 16 Aug, 2009 1 commit
  27. 23 Jul, 2009 2 commits
    • simonpj@microsoft.com's avatar
      Fix Trac #3012: allow more free-wheeling in standalone deriving · aa0c0de9
      simonpj@microsoft.com authored
      In standalone deriving, we now do *not* check side conditions.
      We simply generate the code and typecheck it.  If there's a type
      error, it's the programmer's problem. 
      
      This means that you can do 'deriving instance Show (T a)', where
      T is a GADT, for example, provided of course that the boilerplate
      code does in fact typecheck.
      
      I put some work into getting a decent error message.  In particular
      if there's a type error in a method, GHC will show the entire code
      for that method (since, after all, the user did not write it).
      Most of the changes are to achieve that goal.
      
      Still to come: changes in the documentation.
      aa0c0de9
    • simonpj@microsoft.com's avatar
      Fix Trac #3193: improve line number reporting for equality constraints · 9091712c
      simonpj@microsoft.com authored
      When reporting an error from a failed equality constraint, we were
      setting the *context* but not the *line number* in TcTyFuns.eqInstMisMatch
      As a result, the line number didn't match the context at all.  It's
      trivial to fix.
      
      I'm 99% certain this fixes #3193, but it's too complicated to
      reproduce, so I have not actually tested it.
      9091712c
  28. 16 Jul, 2009 1 commit
    • Simon Marlow's avatar
      Use names like '$fOrdInt' for dfuns (and TF instances), rather than '$f21' · a6f29db0
      Simon Marlow authored
      2 reasons for this:
        - compilation is more predictable.  Adding or removing an instance
          is less likely to force unnecessary recompilation due to
          renumbering other dfun names.
        - it makes it easier to read Core / C-- / asm
      
      The names aren't completely deterministic.  To do that, we'd have to
      include package and module names, which would make the symbol names
      long and reduce readability.  So the compromise is that if there's a
      clash, we disambiguate by adding an integer suffix.  This is fairly
      unlikely in practice unless you're using overlapping instances.
      
      Type family instances are handled in the same way, with the same
      disambiguation strategy.
      a6f29db0
  29. 07 Jul, 2009 1 commit
  30. 06 Jul, 2009 2 commits
  31. 28 May, 2009 1 commit
  32. 27 Apr, 2009 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Equality constraint solver is now externally pure · 296058a1
      chak@cse.unsw.edu.au. authored
      - This patch changes the equality constraint solver such that it does not
        instantiate any type variables that occur in the constraints that are to be
        solved (or in the environment).  Instead, it returns a bag of type bindings.
      - If these type bindings (together with the other results of the solver) are
        discarded, solver invocation has no effect (outside the solver) and can be
        repeated (that's imported for TcSimplifyRestricted).
      - For the type bindings to take effect, the caller of the solver needs to 
        execute them. 
      - The solver will still instantiate type variables thet were created during 
        solving (e.g., skolem flexibles used during type flattening).
      
        See also http://hackage.haskell.org/trac/ghc/wiki/TypeFunctionsSolving
      296058a1
  33. 30 Oct, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Add (a) CoreM monad, (b) new Annotations feature · 9bcd95ba
      simonpj@microsoft.com authored
      This patch, written by Max Bolingbroke,  does two things
      
      1.  It adds a new CoreM monad (defined in simplCore/CoreMonad),
          which is used as the top-level monad for all the Core-to-Core
          transformations (starting at SimplCore).  It supports
             * I/O (for debug printing)
             * Unique supply
             * Statistics gathering
             * Access to the HscEnv, RuleBase, Annotations, Module
          The patch therefore refactors the top "skin" of every Core-to-Core
          pass, but does not change their functionality.
      
      2.  It adds a completely new facility to GHC: Core "annotations".
          The idea is that you can say
             {#- ANN foo (Just "Hello") #-}
          which adds the annotation (Just "Hello") to the top level function
          foo.  These annotations can be looked up in any Core-to-Core pass,
          and are persisted into interface files.  (Hence a Core-to-Core pass
          can also query the annotations of imported things.)  Furthermore,
          a Core-to-Core pass can add new annotations (eg strictness info)
          of its own, which can be queried by importing modules.
      
      The design of the annotation system is somewhat in flux.  It's
      designed to work with the (upcoming) dynamic plug-ins mechanism,
      but is meanwhile independently useful.
      
      Do not merge to 6.10!  
      9bcd95ba
  34. 28 Oct, 2008 2 commits