1. 01 Sep, 2011 1 commit
    • Simon Peyton Jones's avatar
      Allow associated types to have fresh parameters · d2d6bdae
      Simon Peyton Jones authored
      This patch allows
      
           class C a where
             type T a b :: *
           instance C Int
             type T Int b = b -> b
      
      That is, T has a type index 'b' that is not one of the class
      variables.
      
      On the way I did a good deal of refactoring (as usual), especially in
      TcInstDcls.tcLocalInstDecl1, which checks for consistent instantiation
      of the class instance and the type instance.  Less code, more
      expressiveness.  See Note [Checking consistent instantiation]
      d2d6bdae
  2. 22 Aug, 2011 1 commit
  3. 16 Aug, 2011 1 commit
    • Simon Peyton Jones's avatar
      Major improvement to pattern bindings · 49dbe605
      Simon Peyton Jones authored
      This patch makes a number of related improvements
      
      a) Implements the Haskell Prime semantics for pattern bindings
         (Trac #2357).  That is, a pattern binding p = e is typed
         just as if it had been written
              t = e
              f = case t of p -> f
              g = case t of p -> g
              ... etc ...
         where f,g are the variables bound by p. In paricular it's
         ok to say
            (f,g) = (\x -> x, \y -> True)
         and f and g will get propertly inferred types
            f :: a -> a
            g :: a -> Int
      
      b) Eliminates the MonoPatBinds flag altogether.  (For the moment
         it is deprecated and has no effect.)  Pattern bindings are now
         generalised as per (a).  Fixes Trac #2187 and #4940, in the
         way the users wanted!
      
      c) Improves the OutsideIn algorithm generalisation decision.
         Given a definition without a type signature (implying "infer
         the type"), the published algorithm rule is this:
            - generalise *top-level* functions, and
            - do not generalise *nested* functions
         The new rule is
            - generalise a binding whose free variables have
              Guaranteed Closed Types
            - do not generalise other bindings
      
         Generally, a top-level let-bound function has a Guaranteed
         Closed Type, and so does a nested function whose free vaiables
         are top-level functions, and so on. (However a top-level
         function that is bitten by the Monomorphism Restriction does
         not have a GCT.)
      
         Example:
           f x = let { foo y = y } in ...
         Here 'foo' has no free variables, so it is generalised despite
         being nested.
      
      d) When inferring a type f :: ty for a definition f = e, check that
         the compiler would accept f :: ty as a type signature for that
         same definition.  The type is rejected precisely when the type
         is ambiguous.
      
         Example:
            class Wob a b where
              to :: a -> b
              from :: b -> a
      
            foo x = [x, to (from x)]
         GHC 7.0 would infer the ambiguous type
            foo :: forall a b. Wob a b => b -> [b]
         but that type would give an error whenever it is called; and
         GHC 7.0 would reject that signature if given by the
         programmer.  The new type checker rejects it up front.
      
         Similarly, with the advent of type families, ambiguous types are
         easy to write by mistake.  See Trac #1897 and linked tickets for
         many examples.  Eg
            type family F a :: *
            f ::: F a -> Int
            f x = 3
         This is rejected because (F a ~ F b) does not imply a~b.  Previously
         GHC would *infer* the above type for f, but was unable to check it.
         Now even the inferred type is rejected -- correctly.
      
      The main implemenation mechanism is to generalise the abe_wrap
      field of ABExport (in HsBinds), from [TyVar] to HsWrapper. This
      beautiful generalisation turned out to make everything work nicely
      with minimal programming effort.  All the work was fiddling around
      the edges; the core change was easy!
      49dbe605
  4. 02 Aug, 2011 1 commit
  5. 22 Jun, 2011 1 commit
  6. 11 Jun, 2011 1 commit
  7. 26 May, 2011 1 commit
  8. 20 May, 2011 1 commit
  9. 04 May, 2011 1 commit
    • dreixel's avatar
      Remove HsNumTy and TypePati. · fed25228
      dreixel authored
      They belonged to the old generic deriving mechanism, so they can go. Adapted a lot of code as a consequence.
      fed25228
  10. 02 May, 2011 1 commit
  11. 19 Apr, 2011 2 commits
  12. 14 Apr, 2011 1 commit
  13. 12 Apr, 2011 1 commit
  14. 10 Jan, 2011 1 commit
    • simonpj@microsoft.com's avatar
      Do dependency analysis when kind-checking type declarations · 6ea06bbf
      simonpj@microsoft.com authored
      This patch fixes Trac #4875.  The main point is to do dependency
      analysis on type and class declarations, and kind-check them in
      dependency order, so as to improve error messages.
      
      This patch means that a few programs that would typecheck before won't
      typecheck any more; but before we were (naughtily) going beyond
      Haskell 98 without any language-extension flags, and Trac #4875
      convinces me that doing so is a Bad Idea.
      
      Here's an example that won't typecheck any more
             data T a b = MkT (a b)
             type F k = T k Maybe
      
      If you look at T on its own you'd default 'a' to kind *->*;
      and then kind-checking would fail on F.
      
      But GHC currently accepts this program beause it looks at
      the *occurrences* of T.
      6ea06bbf
  15. 18 Dec, 2010 1 commit
  16. 18 Sep, 2010 1 commit
  17. 14 Sep, 2010 1 commit
  18. 13 Sep, 2010 1 commit
  19. 15 Jul, 2010 1 commit
  20. 13 Jul, 2010 1 commit
  21. 07 Jul, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #4127 (and hence #4173) · f87cc9cf
      simonpj@microsoft.com authored
      The change involves a little refactoring, so that the default
      method Ids are brought into scope earlier, before the value
      declarations are compiled.  (Since a value decl may contain
      an instance decl in a quote.)
      
      See Note [Default method Ids and Template Haskell] in
      TcTyClsDcls.
      f87cc9cf
  22. 06 May, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3966: warn about useless UNPACK pragmas · 215ce9f1
      simonpj@microsoft.com authored
      Warning about useless UNPACK pragmas wasn't as easy as I thought.
      I did quite a bit of refactoring, which improved the code by refining
      the types somewhat.  In particular notice that in DataCon, we have
      
          dcStrictMarks   :: [HsBang]
          dcRepStrictness :: [StrictnessMarks]
      
      The former relates to the *source-code* annotation, the latter to
      GHC's representation choice.
      215ce9f1
  23. 09 Apr, 2010 1 commit
  24. 10 Feb, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Keep track of explicit kinding in HsTyVarBndr; plus fix Trac #3845 · 836b1e90
      simonpj@microsoft.com authored
      To print HsTypes correctly we should remember whether the Kind on
      a HsTyVarBndr came from type inference, or was put there by the
      user.  See Note [Printing KindedTyVars] in HsTypes.  So instead of
      changing a UserTyVar to a KindedTyVar during kind checking, we
      simply add a PostTcKind to the UserTyVar.
      
      The change was provoked by Trac #3830, although other changes
      mean that #3830 gets a diferent and better error message now.
      So this patch is simply doing the Right Thing for the future.
      
      This patch also fixes Trac #3845, which was caused by a *type splice*
      not remembering the free *term variables* mentioned in it.  Result
      was that we build a 'let' when it should have been 'letrec'.
      Hence a new FreeVars field in HsSpliceTy.
      
      While I was at it, I got rid of HsSpliceTyOut and use a PostTcKind
      on HsSpliceTy instead, just like on the UserTyVar.
      836b1e90
  25. 20 Jan, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3823, plus warning police in TcRnDriver · dfa43eb4
      simonpj@microsoft.com authored
      The immediate reason for this patch is to fix #3823. This was 
      rather easy: all the work was being done but I was returning
      type_env2 rather than type_env3.  
      
      An unused-veriable warning would have shown this up, so I fixed all
      the other warnings in TcRnDriver.  Doing so showed up at least two
      genuine lurking bugs.  Hurrah.
      dfa43eb4
  26. 24 Jul, 2009 1 commit
  27. 23 Jul, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add tuple sections as a new feature · 58521c72
      simonpj@microsoft.com authored
      This patch adds tuple sections, so that
      
      	(x,,z)  means   \y -> (x,y,z)
      
      Thanks for Max Bolinbroke for doing the hard work.
      
      In the end, instead of using two constructors in HsSyn, I used
      just one (still called ExplicitTuple) whose arguments can be
      	Present (LHsExpr id)
      or	Missing PostTcType
      
      While I was at it, I did a bit of refactoring too.
      58521c72
  28. 22 Jul, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Take account of GADTs when reporting patterm-match overlap · 5b494344
      simonpj@microsoft.com authored
      When matching against a GADT, some of the constructors may be impossible.
      For example
      	data T a where
                T1 :: T Int
                T2 :: T Bool
                T3 :: T a
      
              f :: T Int -> Int
              f T1 = 3
              f T3 = 4
      
      Here, does not have any missing cases, despite omittting T2, because
      T2 :: T Bool.
      
      This patch teaches the overlap checker about GADTs, which happily
      turned out to be rather easy even though the overlap checker needs
      a serious rewrite.
      5b494344
  29. 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
  30. 06 Jul, 2009 1 commit
  31. 02 Jul, 2009 2 commits
    • chak@cse.unsw.edu.au.'s avatar
      1a77fd71
    • simonpj@microsoft.com's avatar
      New syntax for GADT-style record declarations, and associated refactoring · 432b9c93
      simonpj@microsoft.com authored
      The main purpose of this patch is to fix Trac #3306, by fleshing out the
      syntax for GADT-style record declraations so that you have a context in 
      the type.  The new form is
         data T a where
           MkT :: forall a. Eq a => { x,y :: !a } -> T a
      See discussion on the Trac ticket.
      
      The old form is still allowed, but give a deprecation warning.
      
      When we remove the old form we'll also get rid of the one reduce/reduce
      error in the grammar. Hurrah!
      
      While I was at it, I failed as usual to resist the temptation to do lots of
      refactoring.  The parsing of data/type declarations is now much simpler and
      more uniform.  Less code, less chance of errors, and more functionality.
      Took longer than I planned, though.
      
      ConDecl has record syntax, but it was not being used consistently, so I
      pushed that through the compiler.
      432b9c93
  32. 25 Jun, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3323: naughty record selectors again · b4108467
      simonpj@microsoft.com authored
      I boobed when I decoupled record selectors from their data types.
      The most straightforward and robust fix means attaching the TyCon
      of a record selector to its IfaceIdInfo, so 
      
         you'll need to rebuild all .hi files
      
      That said, the fix is easy.
      b4108467
  33. 13 May, 2009 1 commit
  34. 23 Apr, 2009 1 commit
  35. 30 Mar, 2009 1 commit
  36. 16 Mar, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3092 · cc9a63c2
      simonpj@microsoft.com authored
      We were't checking that a 'data/type instance' was extending a family
      type constructor.
      
      Merge to 6.10 if we ever release 6.10.3 (or do it for 6.10.2).
      
      cc9a63c2
  37. 11 Feb, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3017: ensure that we quantify over enough type variables when equalities are involved · e5a8d57c
      simonpj@microsoft.com authored
      The function FunDeps.grow was not doing the right thing when type equality
      constraints were involved.  That wasn't really its fault: its input was
      being filtered by fdPredsOfInsts.
      
      To fix this I did a bit of refactoring, so that the (revolting) fdPredsOfInsts
      is now less important (maybe we can get rid of it in due course).  The 'grow'
      function moves from FunDeps to
      	 Inst.growInstsTyVars
      	 TcMTType.growThetaTyVars
      	 TcMType.growTyVars
      
      The main comments are with the first of these, in
      Note [Growing the tau-tvs using constraints] in Inst.
      
      Push to the branch if conflict free.
      
      e5a8d57c
  38. 04 Feb, 2009 1 commit