Type checking for type synonym families
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 28 Aug 2007 06:18:51 +0000 (06:18 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 28 Aug 2007 06:18:51 +0000 (06:18 +0000)
commit5822cb8d13aa3c05d2b46b4510c13d94b902eb21
tree56f7ed6a9697c4bc119a8d21885370cba8fa3c8b
parentdb14f9df7f2f62039af85ac75ac59a4e22d09787
Type checking for type synonym families

This patch introduces type checking for type families of which associated
type synonyms are a special case. E.g.

        type family Sum n m

        type instance Sum Zero n = n
        type instance Sum (Succ n) m = Succ (Sum n m)

where

        data Zero       -- empty type
        data Succ n     -- empty type

In addition we support equational constraints of the form:

        ty1 ~ ty2

(where ty1 and ty2 are arbitrary tau types) in any context where
type class constraints are already allowed, e.g.

        data Equals a b where
                Equals :: a ~ b => Equals a b

The above two syntactical extensions are disabled by default. Enable
with the -XTypeFamilies flag.

For further documentation about the patch, see:

        * the master plan
          http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions

        * the user-level documentation
          http://haskell.org/haskellwiki/GHC/Indexed_types

The patch is mostly backwards compatible, except for:

        * Some error messages have been changed slightly.

        * Type checking of GADTs now requires a bit more type declarations:
          not only should the type of a GADT case scrutinee be given, but also
          that of any identifiers used in the branches and the return type.

Please report any unexpected behavior and incomprehensible error message
for existing code.

Contributors (code and/or ideas):
        Tom Schrijvers
        Manuel Chakravarty
        Simon Peyton-Jones
        Martin Sulzmann
with special thanks to Roman Leshchinskiy
32 files changed:
compiler/NOTES
compiler/basicTypes/DataCon.lhs
compiler/basicTypes/MkId.lhs
compiler/basicTypes/Var.lhs
compiler/coreSyn/CoreUtils.lhs
compiler/ghci/RtClosureInspect.hs
compiler/hsSyn/HsUtils.lhs
compiler/iface/BuildTyCl.lhs
compiler/iface/MkIface.lhs
compiler/typecheck/Inst.lhs
compiler/typecheck/TcBinds.lhs
compiler/typecheck/TcClassDcl.lhs
compiler/typecheck/TcDeriv.lhs
compiler/typecheck/TcEnv.lhs
compiler/typecheck/TcExpr.lhs
compiler/typecheck/TcHsType.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcMType.lhs
compiler/typecheck/TcPat.lhs
compiler/typecheck/TcRnMonad.lhs
compiler/typecheck/TcRnTypes.lhs
compiler/typecheck/TcRnTypes.lhs-boot [new file with mode: 0644]
compiler/typecheck/TcSimplify.lhs
compiler/typecheck/TcTyClsDecls.lhs
compiler/typecheck/TcTyFuns.lhs [new file with mode: 0644]
compiler/typecheck/TcType.lhs
compiler/typecheck/TcUnify.lhs
compiler/typecheck/TcUnify.lhs-boot
compiler/types/Coercion.lhs
compiler/types/TyCon.lhs
compiler/types/Type.lhs
darcs-all