1. 25 Nov, 2011 1 commit
  2. 16 Nov, 2011 2 commits
  3. 14 Nov, 2011 1 commit
  4. 11 Nov, 2011 1 commit
    • dreixel's avatar
      New kind-polymorphic core · 09015be8
      dreixel authored
      This big patch implements a kind-polymorphic core for GHC. The current
      implementation focuses on making sure that all kind-monomorphic programs still
      work in the new core; it is not yet guaranteed that kind-polymorphic programs
      (using the new -XPolyKinds flag) will work.
      For more information, see http://haskell.org/haskellwiki/GHC/Kinds
  5. 04 Nov, 2011 1 commit
  6. 25 Oct, 2011 3 commits
  7. 23 Oct, 2011 1 commit
  8. 09 Sep, 2011 1 commit
  9. 07 Sep, 2011 1 commit
  10. 06 Sep, 2011 1 commit
    • batterseapower's avatar
      Implement -XConstraintKind · 9729fe7c
      batterseapower authored
      Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact,
      this patch adds a new kind Constraint such that:
        Show :: * -> Constraint
        (?x::Int) :: Constraint
        (Int ~ a) :: Constraint
      And you can write *any* type with kind Constraint to the left of (=>):
      even if that type is a type synonym, type variable, indexed type or so on.
      The following (somewhat related) changes are also made:
       1. We now box equality evidence. This is required because we want
          to give (Int ~ a) the *lifted* kind Constraint
       2. For similar reasons, implicit parameters can now only be of
          a lifted kind. (?x::Int#) => ty is now ruled out
       3. Implicit parameter constraints are now allowed in superclasses
          and instance contexts (this just falls out as OK with the new
          constraint solver)
      Internally the following major changes were made:
       1. There is now no PredTy in the Type data type. Instead
          GHC checks the kind of a type to figure out if it is a predicate
       2. There is now no AClass TyThing: we represent classes as TyThings
          just as a ATyCon (classes had TyCons anyway)
       3. What used to be (~) is now pretty-printed as (~#). The box
          constructor EqBox :: (a ~# b) -> (a ~ b)
       4. The type LCoercion is used internally in the constraint solver
          and type checker to represent coercions with free variables
          of type (a ~ b) rather than (a ~# b)
  11. 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.)
           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.
            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!
  12. 03 Aug, 2011 1 commit
  13. 23 Jul, 2011 1 commit
    • Simon Peyton Jones's avatar
      Reject bad 'deriving' directives (fixes Trac #5287) · 49861e71
      Simon Peyton Jones authored
      The 'deriving' mechanism that infers the context for
      an instance declarations was going into a loop, as a
      result of an instance like
             instance C a b => D [a]
      where the 'b' isn't mentioned in the head.
      This patch identifies those cases.  I also needed to make
      TcErrors generate a suitable error message.  On the way
      I improved the reporting of "ambiguous" variables;
      for example arrowfail001 now generates a better message.
  14. 22 Jun, 2011 2 commits
    • Simon Peyton Jones's avatar
      Add equality superclasses · 940d1309
      Simon Peyton Jones authored
      Hurrah.  At last we can write
         class (F a ~ b) => C a b where { ... }
      This fruit of the fact that equalities are now values,
      and all evidence is handled uniformly.
      The main tricky point is that when translating to Core
      an evidence variable 'v' is represented either as
        either   Var v
        or       Coercion (CoVar v)
      depending on whether or not v is an equality.  This leads
      to a few annoying calls to 'varToCoreExpr'.
    • Simon Peyton Jones's avatar
      Remove "silent superclass parameters" · a9d48fd9
      Simon Peyton Jones authored
      We introduced silent superclass parameters as a way to avoid
      superclass loops, but we now solve that problem a different
      way ("derived" superclass constraints carry no evidence). So
      they aren't needed any more.
      Apart from being a needless complication, they broke DoCon.
      Admittedly in a very obscure way, but still the result is
      hard to explain. To see the details see Trac #5051, with
      test case typecheck/should_compile/T5051.  (The test is
      nice and small!)
  15. 11 Jun, 2011 1 commit
    • Simon Peyton Jones's avatar
      Make TH capable of quoting GADT declarations (Trac #5217) · 5c4a4c4b
      Simon Peyton Jones authored
      Template Haskell doesn't support GADTs directly but
      we can use equality constraints to do the job. Here's
      an example of the dump from splicing such a declaration:
          [d| data T a b
                    T1 :: Int -> T Int Char
                    T2 :: a -> T a a
                    T3 :: a -> T [a] a
                    T4 :: a -> b -> T b [a] |]
          data T a[aQW] b[aQX]
              = (b[aQX] ~ Char, a[aQW] ~ Int) => T1 Int |
                b[aQX] ~ a[aQW] => T2 a[aQW] |
                a[aQW] ~ [b[aQX]] => T3 b[aQX] |
                forall a[aQY]. b[aQX] ~ [a[aQY]] => T4 a[aQY] a[aQW]
  16. 17 May, 2011 1 commit
    • dimitris's avatar
      Introducing: · 9591547f
      dimitris authored
         1) Postponing the application of instances when there
            is a possibility of a given matching. With the addition
            of prioritizing equalities this fixes #5002 and #4981.
         2) Implemented caching of flattening in constraint
            simplification. This improves efficiency (fixes #5030)
         3) Simplified pushing of unsolved wanteds
            (now pushing only equalities) inside implications.
  17. 20 Apr, 2011 1 commit
  18. 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
  19. 31 Mar, 2011 1 commit
  20. 21 Feb, 2011 1 commit
    • simonpj@microsoft.com's avatar
      Fix another fundep error (fixes Trac #4969) · d1796b52
      simonpj@microsoft.com authored
      If I had a pound for every hour Dimitrios and I have spent
      making functional dependencies work right, we'd be rich!
      We had stupidly caused a 'wanted' to be rewritten by a 'derived', with
      resulting abject failure.  As well as fixing the bug, this patch
      refactors some more, adds useful assert and comments.
  21. 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
       * 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
       * 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.
  22. 13 Dec, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix recursive superclasses (again). Fixes Trac #4809. · a3bab050
      simonpj@microsoft.com authored
      This patch finally deals with the super-delicate question of
      superclases in possibly-recursive dictionaries.  The key idea
      is the DFun Superclass Invariant (see TcInstDcls):
           In the body of a DFun, every superclass argument to the
           returned dictionary is
             either   * one of the arguments of the DFun,
             or       * constant, bound at top level
      To establish the invariant, we add new "silent" superclass
      argument(s) to each dfun, so that the dfun does not do superclass
      selection internally.  There's a bit of hoo-ha to make sure that
      we don't print those silent arguments in error messages; a knock
      on effect was a change in interface-file format.
      A second change is that instead of the complex and fragile
      "self dictionary binding" in TcInstDcls and TcClassDcl,
      using the same mechanism for existential pattern bindings.
      See Note [Subtle interaction of recursion and overlap] in TcInstDcls
      and Note [Binding when looking up instances] in InstEnv.
      Main notes are here:
        * Note [Silent Superclass Arguments] in TcInstDcls,
          including the DFun Superclass Invariant
      Main code changes are:
        * The code for MkId.mkDictFunId and mkDictFunTy
        * DFunUnfoldings get a little more complicated;
          their arguments are a new type DFunArg (in CoreSyn)
        * No "self" argument in tcInstanceMethod
        * No special tcSimplifySuperClasss
        * No "dependents" argument to EvDFunApp
         It turns out that it's quite tricky to generate the right
         DFunUnfolding for a specialised dfun, when you use SPECIALISE
         INSTANCE.  For now I've just commented it out (in DsBinds) but
         that'll lose some optimisation, and I need to get back to
  23. 19 Oct, 2010 2 commits
  24. 15 Oct, 2010 2 commits
  25. 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
  26. 04 Oct, 2010 1 commit
  27. 06 Oct, 2010 1 commit
  28. 19 Sep, 2010 2 commits
  29. 18 Sep, 2010 1 commit
  30. 13 Sep, 2010 1 commit
  31. 02 Sep, 2010 1 commit
  32. 31 Aug, 2010 1 commit
  33. 23 Aug, 2010 1 commit