1. 02 Mar, 2015 1 commit
  2. 03 Dec, 2014 1 commit
  3. 02 Dec, 2014 1 commit
  4. 28 Nov, 2014 1 commit
    • Simon Peyton Jones's avatar
      Rename some of the functions in NameSet, to make the uniform with VarSet etc · 7460dafa
      Simon Peyton Jones authored
      For ages NameSet has used different names,
        eg.   addOneToNameSet   rather than    extendNameSet
              nameSetToList     rather than    nameSetElems
      etc.  Other set-like modules use uniform naming conventions.
      This patch makes NameSet follow suit.
      No change in behaviour; this is just renaming.
      I'm doing this just before the fork so that merging is easier.
  5. 20 Nov, 2014 1 commit
    • Jan Stolarek's avatar
      Split SynTyCon to SynonymTyCon and FamilyTyCon · 696fc4ba
      Jan Stolarek authored
      This patch refactors internal representation of type synonyms and type families by splitting them into two separate data constructors of TyCon data type. The main motivation is is that some fields make sense only for type synonyms and some make sense only for type families. This will be even more true with the upcoming injective type families.
      There is also some refactoring of names to keep the naming constistent. And thus tc_kind field has become tyConKind and tc_roles has become tcRoles. Both changes are not visible from the outside of TyCon module.
      Updates haddock submodule
      Reviewers: simonpj
      Differential Revision: https://phabricator.haskell.org/D508
      GHC Trac Issues: #9812
  6. 06 Nov, 2014 1 commit
  7. 26 Sep, 2014 1 commit
  8. 09 Sep, 2014 1 commit
    • Austin Seipp's avatar
      Make Applicative a superclass of Monad · d94de872
      Austin Seipp authored
      This includes pretty much all the changes needed to make `Applicative`
      a superclass of `Monad` finally. There's mostly reshuffling in the
      interests of avoid orphans and boot files, but luckily we can resolve
      all of them, pretty much. The only catch was that
      Alternative/MonadPlus also had to go into Prelude to avoid this.
      As a result, we must update the hsc2hs and haddock submodules.
      Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
      Test Plan: Build things, they might not explode horribly.
      Reviewers: hvr, simonmar
      Subscribers: simonmar
      Differential Revision: https://phabricator.haskell.org/D13
  9. 14 Jul, 2014 1 commit
  10. 12 Jul, 2014 1 commit
  11. 15 May, 2014 2 commits
    • Simon Peyton Jones's avatar
      Refactoring around TyCon.isSynTyCon · 022f8750
      Simon Peyton Jones authored
      * Document isSynTyCon better
      * Add isTypeSyonymTyCon for regular H98 type synonyms
      * Use isTypeSynonymTyCon rather than isSynTyCon where
        the former is really intended
      All arose as part of a bug I introduced when fixing Trac #9102,
      thinking that isSynTyCon meant H98 type syononyms.
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
  12. 05 Apr, 2014 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #8958. · d468cd37
      eir@cis.upenn.edu authored
      We now do role inference on stupid datatype contexts, allowing a
      lightweight role annotation syntax.
  13. 13 Feb, 2014 1 commit
  14. 02 Dec, 2013 1 commit
    • eir@cis.upenn.edu's avatar
      Rejig rejigConRes & friends, doing role checks in a second pass. · 40673406
      eir@cis.upenn.edu authored
      This commit is just a refactoring, intended to make the use of
      rejigConRes (which sorts out the return types of GADT-like constructors)
      less delicate. The idea is that, if we perform role checking in a
      second top-level pass, we can use checkValidDataCon to check for
      valid return types. Previously, checking roles would force the
      rejigConRes thunk before we knew that rejigConRes was safe to call!
  15. 23 Oct, 2013 1 commit
  16. 01 Oct, 2013 1 commit
  17. 18 Sep, 2013 1 commit
    • eir@cis.upenn.edu's avatar
      Change role annotation syntax. · f4046b50
      eir@cis.upenn.edu authored
      This fixes bugs #8185, #8234, and #8246. The new syntax is explained
      in the comments to #8185, appears in the "Roles" subsection of the
      manual, and on the [wiki:Roles] wiki page.
      This change also removes the ability for a role annotation on type
      synonyms, as noted in #8234.
  18. 13 Sep, 2013 1 commit
  19. 11 Sep, 2013 1 commit
  20. 04 Sep, 2013 1 commit
    • Simon Peyton Jones's avatar
      Make role inference work on the source type of a data con · e30c84cb
      Simon Peyton Jones authored
      When inferring roles it is Much More Kosher to work on the source
      type, as written by the user, rather than the representation type as
      computed by GHC.  Error messages may be better and, more subtly, the
      representation type is the result of a pretty complicated calculation
      and I'm worried about accidental cycles.
  21. 02 Aug, 2013 1 commit
  22. 03 Apr, 2013 1 commit
  23. 25 Jan, 2013 1 commit
    • 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
      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
      The inference for the group is done in TcTyDecls, the same place
      that infers which data types are recursive, another global question.
  24. 22 Dec, 2012 1 commit
    • eir@cis.upenn.edu's avatar
      Implement overlapping type family instances. · 8366792e
      eir@cis.upenn.edu authored
      An ordered, overlapping type family instance is introduced by 'type
      where', followed by equations. See the new section in the user manual
      ( for details. The canonical example is Boolean equality at the
      type family Equals (a :: k) (b :: k) :: Bool
      type instance where
        Equals a a = True
        Equals a b = False
      A branched family instance, such as this one, checks its equations in
      and applies only the first the matches. As explained in the note
      checking within groups] in FamInstEnv.lhs, we must be careful not to
      say, (Equals Int b) to False, because b might later unify with Int.
      This commit includes all of the commits on the overlapping-tyfams
      branch. SPJ
      requested that I combine all my commits over the past several months
      into one
      monolithic commit. The following GHC repos are affected: ghc, testsuite,
      utils/haddock, libraries/template-haskell, and libraries/dph.
      Here are some details for the interested:
      - The definition of CoAxiom has been moved from TyCon.lhs to a
        new file CoAxiom.lhs. I made this decision because of the
        number of definitions necessary to support BranchList.
      - BranchList is a GADT whose type tracks whether it is a
        singleton list or not-necessarily-a-singleton-list. The reason
        I introduced this type is to increase static checking of places
        where GHC code assumes that a FamInst or CoAxiom is indeed a
        singleton. This assumption takes place roughly 10 times
        throughout the code. I was worried that a future change to GHC
        would invalidate the assumption, and GHC might subtly fail to
        do the right thing. By explicitly labeling CoAxioms and
        FamInsts as being Unbranched (singleton) or
        Branched (not-necessarily-singleton), we make this assumption
        explicit and checkable. Furthermore, to enforce the accuracy of
        this label, the list of branches of a CoAxiom or FamInst is
        stored using a BranchList, whose constructors constrain its
        type index appropriately.
      I think that the decision to use BranchList is probably the most
      controversial decision I made from a code design point of view.
      Although I provide conversions to/from ordinary lists, it is more
      efficient to use the brList... functions provided in CoAxiom than
      always to convert. The use of these functions does not wander far
      from the core CoAxiom/FamInst logic.
      BranchLists are motivated and explained in the note [Branched axioms] in
      - The CoAxiom type has changed significantly. You can see the new
        type in CoAxiom.lhs. It uses a CoAxBranch type to track
        branches of the CoAxiom. Correspondingly various functions
        producing and consuming CoAxioms had to change, including the
        binary layout of interface files.
      - To get branched axioms to work correctly, it is important to have a
        of type "apartness": two types are apart if they cannot unify, and no
        substitution of variables can ever get them to unify, even after type
        simplification. (This is different than the normal failure to unify
        of the type family bit.) This notion in encoded in tcApartTys, in
        Because apartness is finer-grained than unification, the tcUnifyTys
        calls tcApartTys.
      - CoreLinting axioms has been updated, both to reflect the new
        form of CoAxiom and to enforce the apartness rules of branch
        application. The formalization of the new rules is in
      - The FamInst type (in types/FamInstEnv.lhs) has changed
        significantly, paralleling the changes to CoAxiom. Of course,
        this forced minor changes in many files.
      - There are several new Notes in FamInstEnv.lhs, including one
        discussing confluent overlap and why we're not doing it.
      - lookupFamInstEnv, lookupFamInstEnvConflicts, and
        lookup_fam_inst_env' (the function that actually does the work)
        have all been more-or-less completely rewritten. There is a
        Note [lookup_fam_inst_env' implementation] describing the
        implementation. One of the changes that affects other files is
        to change the type of matches from a pair of (FamInst, [Type])
        to a new datatype (which now includes the index of the matching
        branch). This seemed a better design.
      - The TySynInstD constructor in Template Haskell was updated to
        use the new datatype TySynEqn. I also bumped the TH version
        number, requiring changes to DPH cabal files. (That's why the
        DPH repo has an overlapping-tyfams branch.)
      - As SPJ requested, I refactored some of the code in HsDecls:
       * splitting up TyDecl into SynDecl and DataDecl, correspondingly
         changing HsTyDefn to HsDataDefn (with only one constructor)
       * splitting FamInstD into TyFamInstD and DataFamInstD and
         splitting FamInstDecl into DataFamInstDecl and TyFamInstDecl
       * making the ClsInstD take a ClsInstDecl, for parallelism with
         InstDecl's other constructors
       * changing constructor TyFamily into FamDecl
       * creating a FamilyDecl type that stores the details for a family
         declaration; this is useful because FamilyDecls can appear in classes
         other decls cannot
       * restricting the associated types and associated type defaults for a
       * class
         to be the new, more restrictive types
       * splitting cid_fam_insts into cid_tyfam_insts and cid_datafam_insts,
         according to the new types
       * perhaps one or two more that I'm overlooking
      None of these changes has far-reaching implications.
      - The user manual, section, is updated to describe the new type
  25. 18 Sep, 2012 1 commit
    • Simon Peyton Jones's avatar
      Make a start towards eta-rules and injective families · 58470fb7
      Simon Peyton Jones authored
      * Make Any into a type family (which it should always have been)
        This is to support the future introduction of eta rules for
        product types (see email on ghc-users title "PolyKind issue"
        early Sept 2012)
      * Add the *internal* data type support for
          (a) closed type families [so that you can't give
              type instance for 'Any']
          (b) injective type families [because Any is really
        This amounts to two boolean flags on the SynFamilyTyCon
        constructor of TyCon.SynTyConRhs.
      There is some knock-on effect, but all of a routine nature.
      It remains to offer source syntax for either closed or
      injective families.
  26. 17 Sep, 2012 1 commit
  27. 20 Apr, 2012 1 commit
    • 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
      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.
  28. 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
             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)
  29. 13 Jan, 2012 1 commit
  30. 19 Dec, 2011 1 commit
  31. 04 Nov, 2011 1 commit
  32. 24 Oct, 2011 3 commits
  33. 22 Oct, 2011 1 commit
    • batterseapower's avatar
      Implement relaxed superclass cycle check · 5ff06e90
      batterseapower authored
      This new check permits code such as the following:
        class B cls a where
          meth :: cls a => a -> a
        class B C a => C a where
      This code can never cause the constraint solver to diverge, adding
      infinite numbers of superclasses, because C is not mentioned as a
      superclass of B.
  34. 21 Sep, 2011 1 commit
  35. 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)
  36. 05 Sep, 2011 1 commit
  37. 26 May, 2011 1 commit