1. 21 Dec, 2012 1 commit
  2. 19 Dec, 2012 1 commit
  3. 14 Dec, 2012 1 commit
    • Simon Peyton Jones's avatar
      Major refactoring of the way that UNPACK pragmas are handled · faa8ff40
      Simon Peyton Jones authored
      The situation was pretty dire.  The way in which data constructors
      were handled, notably the mapping between their *source* argument types
      and their *representation* argument types (after seq'ing and unpacking)
      was scattered in three different places, and hard to keep in sync.
      
      Now it is all in one place:
      
       * The dcRep field of a DataCon gives its representation,
         specified by a DataConRep
      
       * As well as having the wrapper, the DataConRep has a "boxer"
         of type DataConBoxer (defined in MkId for loopy reasons).
         The boxer used at a pattern match to reconstruct the source-level
         arguments from the rep-level bindings in the pattern match.
      
       * The unboxing in the wrapper and the boxing in the boxer are dual,
         and are now constructed together, by MkId.mkDataConRep. This is
         the key function of this change.
      
       * All the computeBoxingStrategy code in TcTyClsDcls disappears.
      
      Much nicer.
      
      There is a little bit of refactoring left to do; the strange
      deepSplitProductType functions are now called only in WwLib, so
      I moved them there, and I think they could be tidied up further.
      faa8ff40
  4. 30 Nov, 2012 2 commits
  5. 10 Nov, 2012 1 commit
  6. 23 Oct, 2012 1 commit
  7. 03 Oct, 2012 1 commit
    • Simon Peyton Jones's avatar
      This big patch re-factors the way in which arrow-syntax is handled · ba56d20d
      Simon Peyton Jones authored
      All the work was done by Dan Winograd-Cort.
      
      The main thing is that arrow comamnds now have their own
      data type HsCmd (defined in HsExpr).  Previously it was
      punned with the HsExpr type, which was jolly confusing,
      and made it hard to do anything arrow-specific.
      
      To make this work, we now parameterise
        * MatchGroup
        * Match
        * GRHSs, GRHS
        * StmtLR and friends
      over the "body", that is the kind of thing they
      enclose.  This "body" parameter can be instantiated to
      either LHsExpr or LHsCmd respectively.
      
      Everything else is really a knock-on effect; there should
      be no change (yet!) in behaviour.  But it should be a sounder
      basis for fixing bugs.
      ba56d20d
  8. 03 Sep, 2012 1 commit
  9. 31 Aug, 2012 1 commit
  10. 16 Aug, 2012 1 commit
  11. 24 Jul, 2012 1 commit
  12. 16 Jul, 2012 2 commits
  13. 13 Jun, 2012 1 commit
    • Simon Peyton Jones's avatar
      Simplify the implementation of Implicit Parameters · 5a8ac0f8
      Simon Peyton Jones authored
      This patch re-implements implicit parameters via a class
      with a functional dependency:
      
          class IP (n::Symbol) a | n -> a where
            ip :: a
      
      This definition is in the library module GHC.IP. Notice
      how it use a type-literal, so we can have constraints like
         IP "x" Int
      Now all the functional dependency machinery works right to make
      implicit parameters behave as they should.
      
      Much special-case processing for implicit parameters can be removed
      entirely. One particularly nice thing is not having a dedicated
      "original-name cache" for implicit parameters (the nsNames field of
      NameCache).  But many other cases disappear:
      
        * BasicTypes.IPName
        * IPTyCon constructor in Tycon.TyCon
        * CIPCan constructor  in TcRnTypes.Ct
        * IPPred constructor  in Types.PredTree
      
      Implicit parameters remain special in a few ways:
      
       * Special syntax.  Eg the constraint (IP "x" Int) is parsed
         and printed as (?x::Int).  And we still have local bindings
         for implicit parameters, and occurrences thereof.
      
       * A implicit-parameter binding  (let ?x = True in e) amounts
         to a local instance declaration, which we have not had before.
         It just generates an implication contraint (easy), but when
         going under it we must purge any existing bindings for
         ?x in the inert set.  See Note [Shadowing of Implicit Parameters]
         in TcSimplify
      
       * TcMType.sizePred classifies implicit parameter constraints as size-0,
         as before the change
      
      There are accompanying patches to libraries 'base' and 'haddock'
      
      All the work was done by Iavor Diatchki
      5a8ac0f8
  14. 11 May, 2012 1 commit
    • Simon Peyton Jones's avatar
      Refactor LHsTyVarBndrs to fix Trac #6081 · fc8959ac
      Simon Peyton Jones authored
      This is really a small change, but it touches a lot of files quite
      significantly. The real goal is to put the implicitly-bound kind
      variables of a data/class decl in the right place, namely on the
      LHsTyVarBndrs type, which now looks like
      
        data LHsTyVarBndrs name
          = HsQTvs { hsq_kvs :: [Name]
                   , hsq_tvs :: [LHsTyVarBndr name]
            }
      
      This little change made the type checker neater in a number of
      ways, but it was fiddly to push through the changes.
      fc8959ac
  15. 01 May, 2012 1 commit
    • Simon Peyton Jones's avatar
      Tidy up a remaining glitch in unification · 67c793a3
      Simon Peyton Jones authored
      There was one place, in type checking parallel list comprehensions
      where we were unifying types, but had no convenient way to use the
      resulting coercion; instead we just checked that it was Refl.  This
      was Wrong Wrong; it might fail unpredicably in a GADT-like situation,
      and it led to extra error-generation code used only in this one place.
      
      This patch tidies it all up, by moving the 'return' method from the
      *comprehension* to the ParStmtBlock. The latter is a new data type,
      now used for each sub-chunk of a parallel list comprehension.
      
      Because of the data type change, quite a few modules are touched,
      but only in a fairly trivial way. The real changes are in TcMatches
      (and corresponding desugaring); plus deleting code from TcUnify.
      
      This patch also fixes the pretty-printing bug in Trac #6060
      67c793a3
  16. 20 Apr, 2012 2 commits
    • Simon Peyton Jones's avatar
      c284511c
    • Simon Peyton Jones's avatar
      Do SCC on instance declarations (fixes Trac #5715) · fa9fdc28
      Simon Peyton Jones authored
      The trouble here is that given
      
          {-# LANGUAGE DataKinds, TypeFamilies #-}
          data instance Foo a = Bar (Bar a)
      
      we want to get a sensible message that we can't use the promoted 'Bar'
      constructor until after its definition; it's a staging error.  Bud the
      staging mechanism that we use for vanilla data declarations don't work
      here.
      
      Solution is to perform strongly-connected component analysis on the
      instance declarations. But that in turn means that we need to track
      free-variable information on more HsSyn declarations, which is why
      so many files are touched.  All the changes are boiler-platey except
      the ones in TcInstDcls.
      fa9fdc28
  17. 13 Apr, 2012 1 commit
    • Simon Peyton Jones's avatar
      Allow kind-variable binders in type signatures · c5554f82
      Simon Peyton Jones authored
      This is the last major addition to the kind-polymorphism story,
      by allowing (Trac #5938)
      
       type family F a   -- F :: forall k. k -> *
       data T a          -- T :: forall k. k -> *
       type instance F (T (a :: Maybe k)) = Char
      
      The new thing is the explicit 'k' in the type signature on 'a',
      which itself is inside a type pattern for F.
      
      Main changes are:
      
      * HsTypes.HsBSig now has a *pair* (kvs, tvs) of binders,
        the kind variables and the type variables
      
      * extractHsTyRdrTyVars returns a pair (kvs, tvs)
        and the function itself has moved from RdrHsSyn to RnTypes
      
      * Quite a bit of fiddling with
           TcHsType.tcHsPatSigType and tcPatSig
        which have become a bit simpler.  I'm still not satisfied
        though.  There's some consequential fiddling in TcRules too.
      
      * Removed the unused HsUtils.collectSigTysFromPats
      
      There's a consequential wibble to Haddock too
      c5554f82
  18. 06 Apr, 2012 1 commit
  19. 02 Apr, 2012 1 commit
  20. 24 Mar, 2012 1 commit
  21. 22 Mar, 2012 1 commit
  22. 18 Mar, 2012 1 commit
  23. 14 Mar, 2012 2 commits
    • Simon Peyton Jones's avatar
      Deal with kind variables brought into scope by a kind signature · 431c05b3
      Simon Peyton Jones authored
      This fixes Trac #5937, where a kind variable is mentioned only
      in the kind signature of a GADT
         data SMaybe :: (k -> *) -> Maybe k -> * where ...
      
      The main change is that the tcdKindSig field of TyData and TyFamily
      now has type Maybe (HsBndrSig (LHsKind name)), where the HsBndrSig
      part deals with the kind variables that the signature may bind.
      
      I also removed the now-unused PostTcKind field of UserTyVar and
      KindedTyVar.
      431c05b3
    • Simon Peyton Jones's avatar
      Deal with kind variables brought into scope by a kind signature · 54eb0301
      Simon Peyton Jones authored
      This fixes Trac #5937, where a kind variable is mentioned only
      in the kind signature of a GADT
         data SMaybe :: (k -> *) -> Maybe k -> * where ...
      
      The main change is that the tcdKindSig field of TyData and TyFamily
      now has type Maybe (HsBndrSig (LHsKind name)), where the HsBndrSig
      part deals with the kind variables that the signature may bind.
      
      I also removed the now-unused PostTcKind field of UserTyVar and
      KindedTyVar.
      54eb0301
  24. 02 Mar, 2012 1 commit
    • Simon Peyton Jones's avatar
      Hurrah! This major commit adds support for scoped kind variables, · 3bf54e78
      Simon Peyton Jones authored
      which (finally) fills out the functionality of polymorphic kinds.
      It also fixes numerous bugs.
      
      Main changes are:
      
      Renaming stuff
      ~~~~~~~~~~~~~~
      * New type in HsTypes:
           data HsBndrSig sig = HsBSig sig [Name]
        which is used for type signatures in patterns, and kind signatures
        in types.  So when you say
             f (x :: [a]) = x ++ x
        or
             data T (f :: k -> *) (x :: *) = MkT (f x)
        the signatures in both cases are a HsBndrSig.
      
      * The [Name] in HsBndrSig records the variables bound by the
        pattern, that is 'a' in the first example, 'k' in the second,
        and nothing in the third.  The renamer initialises the field.
      
      * As a result I was able to get rid of
           RnHsSyn.extractHsTyNames :: LHsType Name -> NameSet
        and its friends altogether.  Deleted the entire module!
        This led to some knock-on refactoring; in particular the
        type renamer now returns the free variables just like the
        term renamer.
      
      Kind-checking types: mainly TcHsType
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      A major change is that instead of kind-checking types in two
      passes, we now do one. Under the old scheme, the first pass did
      kind-checking and (hackily) annotated the HsType with the
      inferred kinds; and the second pass desugared the HsType to a
      Type.  But now that we have kind variables inside types, the
      first pass (TcHsType.tc_hs_type) can go straight to Type, and
      zonking will squeeze out any kind unification variables later.
      
      This is much nicer, but it was much more fiddly than I had expected.
      
      The nastiest corner is this: it's very important that tc_hs_type
      uses lazy constructors to build the returned type. See
      Note [Zonking inside the knot] in TcHsType.
      
      Type-checking type and class declarations: mainly TcTyClsDecls
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      I did tons of refactoring in TcTyClsDecls.  Simpler and nicer now.
      
      Typechecking bindings: mainly TcBinds
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      I rejigged (yet again) the handling of type signatures in TcBinds.
      It's a bit simpler now.  The main change is that tcTySigs goes
      right through to a TcSigInfo in one step; previously it was split
      into two, part here and part later.
      
      Unsafe coercions
      ~~~~~~~~~~~~~~~~
      Usually equality coercions have exactly the same kind on both
      sides.  But we do allow an *unsafe* coercion between Int# and Bool,
      say, used in
          case error Bool "flah" of { True -> 3#; False -> 0# }
      -->
          (error Bool "flah") |> unsafeCoerce Bool Int#
      
      So what is the instantiation of (~#) here?
         unsafeCoerce Bool Int# :: (~#) ??? Bool Int#
      I'm using OpenKind here for now, but it's un-satisfying that
      the lhs and rhs of the ~ don't have precisely the same kind.
      
      More minor
      ~~~~~~~~~~
      * HsDecl.TySynonym has its free variables attached, which makes
        the cycle computation in TcTyDecls.mkSynEdges easier.
      
      * Fixed a nasty reversed-comparison bug in FamInstEnv:
        @@ -490,7 +490,7 @@ lookup_fam_inst_env' match_fun one_sided ie fam tys
           n_tys = length tys
           extra_tys = drop arity tys
           (match_tys, add_extra_tys)
      -       | arity > n_tys = (take arity tys, \res_tys -> res_tys ++ extra_tys)
      +       | arity < n_tys = (take arity tys, \res_tys -> res_tys ++ extra_tys)
              | otherwise     = (tys,            \res_tys -> res_tys)
      3bf54e78
  25. 22 Feb, 2012 1 commit
  26. 17 Feb, 2012 2 commits
  27. 16 Feb, 2012 2 commits
  28. 06 Feb, 2012 1 commit
    • Simon Peyton Jones's avatar
      Refactor HsDecls again, to put family instances in InstDecl · f92591de
      Simon Peyton Jones authored
      This continues the clean up of the front end.  Since they
      were first invented, type and data family *instance* decls
      have been in the TyClDecl data type, even though they always
      treated separately.
      
      This patch takes a step in the right direction
        * The InstDecl type now includes both class instances and
          type/data family instances
      
        * The hs_tyclds field of HsGroup now never has any family
          instance declarations in it
      
      However a family instance is still a TyClDecl.  It should really
      be a separate type, but that's the next step.
      
      All this was provoked by fixing Trac #5792 in the HEAD.
      (I did a less invasive fix on the branch.)
      f92591de
  29. 25 Jan, 2012 1 commit
    • Iavor S. Diatchki's avatar
      Add support for type-level "strings". · 5851f847
      Iavor S. Diatchki authored
      These are types that look like "this" and "that".
      They are of kind `Symbol`, defined in module `GHC.TypeLits`.
      
      For each type-level symbol `X`, we have a singleton type, `TSymbol X`.
      
      The value of the singleton type can be named with the overloaded
      constant `tSymbol`.  Here is an example:
      
      tSymbol :: TSymbol "Hello"
      5851f847
  30. 17 Jan, 2012 1 commit
  31. 09 Jan, 2012 1 commit
    • Iavor S. Diatchki's avatar
      Change -XTypeOperators to treat all type-operators as type-constructors. · 85926ae6
      Iavor S. Diatchki authored
      Previously, only type operators starting with ":" were type constructors,
      and writing "+" in a type resulted in a type variable.  Now, type
      variables are always ordinary identifiers, and all operators are treated
      as constructors.  One can still write type variables in infix form though,
      for example, "a `fun` b" is a type expression with 3 type variables: "a",
      "fun", and "b".
      
      Writing (+) in an import/export list always refers to the value (+)
      and not the type.   To refer to the type one can write either "type (+)",
      or provide an explicit suobrdinate list (e.g., "(+)()").  For clarity,
      one can also combine the two, for example "type (+)(A,B,C)" is also
      accepted and means the same thing as "(+)(A,B,C)" (i.e., export the type
      (+), with the constructors A,B,and C).
      85926ae6
  32. 23 Dec, 2011 2 commits
  33. 19 Dec, 2011 1 commit