1. 15 May, 2013 1 commit
  2. 03 May, 2013 1 commit
    • Simon Peyton Jones's avatar
      Fix kind quantification (again) · 7a7530a9
      Simon Peyton Jones authored
      We simply weren't quantifying kind variables at the points we
      were claiming.  In paritcular, in
           forall (a:k). blah
      we quantify the 'k' around the 'forall a', provided k isn't
      already in scope
      7a7530a9
  3. 30 Apr, 2013 2 commits
  4. 21 Apr, 2013 1 commit
  5. 14 Feb, 2013 1 commit
    • Simon Peyton Jones's avatar
      Add OverloadedLists, allowing list syntax to be overloaded · 3234a4ad
      Simon Peyton Jones authored
      This work was all done by
         Achim Krause <achim.t.krause@gmail.com>
         George Giorgidze <giorgidze@gmail.com>
         Weijers Jeroen <jeroen.weijers@uni-tuebingen.de>
      
      It allows list syntax, such as [a,b], [a..b] and so on, to be
      overloaded so that it works for a variety of types.
      
      The design is described here:
          http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
      
      Eg. you can use it for maps, so that
              [(1,"foo"), (4,"bar")] :: Map Int String
      
      The main changes
       * The ExplicitList constructor of HsExpr gets witness field
       * Ditto ArithSeq constructor
       * Ditto the ListPat constructor of HsPat
      
      Everything else flows from this.
      3234a4ad
  6. 30 Jan, 2013 1 commit
  7. 29 Jan, 2013 1 commit
  8. 25 Jan, 2013 2 commits
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
      Refactor and improve the promotion inference · 09ff0e0d
      Simon Peyton Jones authored
      It should be the case that either an entire mutually recursive
      group of data type declarations can be promoted, or none of them.
      It's really odd to promote some data constructors of a type but
      not others. Eg
        data T a = T1 a | T2 Int
      Here T1 is sort-of-promotable but T2 isn't (becuase Int isn't
      promotable).
      
      This patch makes it all-or-nothing. At the same time I've made
      the TyCon point to its promoted cousin (via the tcPromoted field
      of an AlgTyCon), as well as vice versa (via the ty_con field of
      PromotedTyCon).
      
      The inference for the group is done in TcTyDecls, the same place
      that infers which data types are recursive, another global question.
      09ff0e0d
  9. 08 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Re-engineer the ambiguity test for user type signatures · 97db0edc
      Simon Peyton Jones authored
      Two main changes. First, re-engineer the ambiguity test.  Previously
      TcMType.checkAmbiguity used a rather syntactic test to detect some
      types that are certainly ambiguous.  But a much easier test is available,
      and it is used for inferred types in TcBinds. Namely
          <type> is ambiguous
      iff
         <type> `TcUnify.isSubType` <type>
      fails to hold, where "isSubType" means "is provably more polymorphic than".
      Example:
            C a => Int
      is ambiguous, because isSubType instantiates the (C a => Int)
      to (C alpha => Int) and then tries to deduce (C alpha) from (C a). This is
      Martin Sulzmann's definition of ambiguity.  (Defn 10 of "Understanding
      functional dependencies via constraint handling rules", JFP.)
      
      This change is neat, reduces code, and correctly rejects more programs.
      However is *is* just possible to have a useful program that would be
      rejected. For example
                class C a b
                f :: C Int b => Int -> Int
      Here 'f' would be rejected as having an ambiguous type. But it is
      just possible that, at a *call* site there might be an instance
      declaration  instance C Int b, which does not constrain 'b' at all.
      This is pretty strange -- why is 'b' overloaded at all? -- but it's
      possible, so I also added a flag -XAllowAmbiguousTypes that simply
      removes the ambiguity check.  Let's see if anyone cares.  Meanwhile
      the earlier error report will be useful for everyone else.
      
      A handful of regression tests had to be adjusted as a result, because
      they used ambiguous types, somewhat accidentally.
      
      Second, split TcMType (already too large) into two
      
        * TcMType: a low-level module dealing with monadic operations like
          zonking, creating new evidence variables, etc
      
        * TcValidity: a brand-new higher-level module dealing with
          validity checking for types: checkValidType, checkValidInstance,
          checkFamInstPats etc
      
      Apart from the fact that TcMType was too big, this allows TcValidity
      to import TcUnify(tcSubType) without causing a loop.
      97db0edc
  10. 19 Dec, 2012 1 commit
  11. 26 Nov, 2012 1 commit
  12. 21 Nov, 2012 1 commit
  13. 31 Oct, 2012 1 commit
    • Simon Peyton Jones's avatar
      Do not instantiate unification variables with polytypes · 10f83429
      Simon Peyton Jones authored
      Without -XImpredicativeTypes, the typing rules say that a function
      should be instantiated only at a *monotype*.  In implementation terms,
      that means that a unification variable should not unify with a type
      involving foralls.  But we were not enforcing that rule, and that
      gave rise to some confusing error messages, such as
        Trac #7264, #6069
      
      This patch adds the test for foralls.  There are consequences
      
       * I put the test in occurCheckExpand, since that is where we see if a
         type can unify with a given unification variable.  So
         occurCheckExpand has to get DynFlags, so it can test for
         -XImpredicativeTypes
      
       * We want this to work
            foo :: (forall a. a -> a) -> Int
            foo = error "foo"
         But that means instantiating error at a polytype!  But error is special
         already because you can instantiate it at an unboxed type like Int#.
         So I extended the specialness to allow type variables of openTypeKind
         to unify with polytypes, regardless of -XImpredicativeTypes.
      
         Conveniently, this works in TcUnify.matchExpectedFunTys, which generates
         unification variable for the function arguments, which can be polymorphic.
      
       * GHC has a special typing rule for ($) (see Note [Typing rule
         for ($)] in TcExpr).  It unifies the argument and result with a
         unification variable to exclude unboxed types -- but that means I
         now need a kind of unificatdion variable that *can* unify with a
         polytype.
      
         So for this sole case I added PolyTv to the data type TcType.MetaInfo.
         I suspect we'll find mor uses for this, and the changes are tiny,
         but it still feel a bit of a hack.  Well the special rule for ($)
         is a hack!
      
      There were some consequential changes in error reporting (TcErrors).
      10f83429
  14. 19 Oct, 2012 3 commits
  15. 15 Oct, 2012 1 commit
  16. 12 Oct, 2012 1 commit
    • Simon Peyton Jones's avatar
      Ensure we produce a FunTy for functions (Trac #7312) · 9991890d
      Simon Peyton Jones authored
      The issue here was with a function type written prefix
        (->) a b
      where we were not generating a FunTy, which blew the
      invariant that function types are always FunTys.  We
      can't look at the TyCon directly because it may be
      knot-tied, so we look at the name instead.
      9991890d
  17. 28 Sep, 2012 1 commit
    • Simon Peyton Jones's avatar
      Refactor the handling of kind errors · 9a058b17
      Simon Peyton Jones authored
      * Treat kind-equality constraints as *derived* equalities,
        with no evidence.  That is really what they are at the moment.
      
      * Get rid of EvKindCast and friends.
      
      * Postpone kind errors properly to the constraint solver
        (lots of small knock-on effects)
      
      I moved SwapFlag to BasicTypes as well
      9a058b17
  18. 21 Sep, 2012 1 commit
  19. 17 Sep, 2012 1 commit
  20. 10 Sep, 2012 1 commit
  21. 06 Sep, 2012 1 commit
  22. 15 Aug, 2012 1 commit
  23. 14 Aug, 2012 1 commit
  24. 14 Jul, 2012 1 commit
  25. 10 Jul, 2012 1 commit
    • Simon Peyton Jones's avatar
      More changes to kind inference for type and class declarations · 3fe3ef50
      Simon Peyton Jones authored
      These should fix #7024 and #7022, among others.
      
      The main difficulty was that we were getting occ-name clashes
      between kind and type variables in TyCons, when spat into an
      interface file. The new scheme is to tidy TyCons during the
      conversoin into IfaceSyn, rather than trying to generate them
      pre-tidied, which was the already-unsatisfactory previous plan.
      
      There is the usual wave of refactorig as well.
      3fe3ef50
  26. 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
  27. 12 Jun, 2012 1 commit
  28. 07 Jun, 2012 2 commits
    • Simon Peyton Jones's avatar
      177134e9
    • Simon Peyton Jones's avatar
      Support polymorphic kind recursion · c9117200
      Simon Peyton Jones authored
      This is (I hope) the last major patch for kind polymorphism.
      The big new feature is polymorphic kind recursion when you
      supply a complete kind signature for a type constructor.
      (I've documented it in the user manual too.)
      
      This fixes Trac #6137, #6093, #6049.
      
      The patch also makes type/data families less polymorphic by default.
         data family T a
      now defaults to T :: * -> *
      If you want T :: forall k. k -> *, use
         data family T (a :: k)
      
      This defaulting to * is done whenever there is a
      "complete, user-specified kind signature", something that is
      carefully defined in the user manual.
      
      Hurrah!
      c9117200
  29. 05 Jun, 2012 1 commit
  30. 24 May, 2012 1 commit
  31. 15 May, 2012 1 commit
    • batterseapower's avatar
      Support code generation for unboxed-tuple function arguments · 09987de4
      batterseapower authored
      This is done by a 'unarisation' pre-pass at the STG level which
      translates away all (live) binders binding something of unboxed
      tuple type.
      
      This has the following knock-on effects:
        * The subkind hierarchy is vastly simplified (no UbxTupleKind or ArgKind)
        * Various relaxed type checks in typechecker, 'foreign import prim' etc
        * All case binders may be live at the Core level
      09987de4
  32. 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
  33. 27 Apr, 2012 1 commit
  34. 25 Apr, 2012 2 commits
    • Simon Peyton Jones's avatar
      Fix typo · ebd7226a
      Simon Peyton Jones authored
      ebd7226a
    • Simon Peyton Jones's avatar
      More fixes to kind polymorphism, fixes Trac #6035, #6036 · 2316a90d
      Simon Peyton Jones authored
      * Significant refactoring in tcFamPats and tcConDecl
      
      * It seems that we have to allow KindVars (not just
        TcKindVars during kind unification.  See
        Note [Unifying kind variables] in TcUnify.
      
      * Be consistent about zonkQuantifiedTyVars
      
      * Split the TcType->TcType zonker (in TcMType)
         from the TcType->Type   zonker (in TcHsSyn)
        The clever parameterisation was doing my head in,
        and it's only a small function
      
      * Remove some dead code (tcTyVarBndrsGen)
      2316a90d