cvs commit: fptools/ghc/compiler/deSugar DsMeta.hs
Convert.lhs HsDecls.lhs fptools/ghc/compiler/main HscStats.lhs
fptools/ghc/compiler/parser Parser.y.pp ParserCore.y RdrHsSyn.lhs
fptools/ghc/compiler/rename RnBinds.lhs RnNames.lhs RnSource.lhs ...
chak at haskell.org
chak at haskell.org
Tue May 10 00:11:28 EDT 2005
chak 2005/05/09 21:11:27 PDT
Modified files: (Branch: ghc-assoc-branch)
ghc/compiler/hsSyn Convert.lhs HsDecls.lhs
ghc/compiler/parser Parser.y.pp ParserCore.y RdrHsSyn.lhs
ghc/compiler/rename RnBinds.lhs RnNames.lhs RnSource.lhs
ghc/compiler/typecheck TcInstDcls.lhs TcRnMonad.lhs
Associated Data Types
This is the initial commit towards implementing associated data types (ie,
data and newtype declarations in type classes). The language extension
and implementation follows the specification in the corresponding POPL'05
paper. However, there are some refinements; the currently implemented ones
are listed below.
This commit covers:
* HsSyn and parser extension to allow data and newtype declarations in class
and instance declarations.
* Renamer processes associated data/newtype declarations and propagates
associated declarations from instance to the toplevel (in particular, the
data constructors get into the GlobalRdrEnv).
* Kind checking is performed on associated data type declarations (ie, they
are traversed in the kind checking knot of TcTyClsDecls).
Refinement of the specification in the POPL'05 paper:
* Kind signatures can only occur on the type variables that are in excess of
the class parameters in an associated type declaration (in a type class
declaration). Rationale: The binding position for the class parameters is
the class head. That's where the signatures should be.
* Associated data type definitions (in instances) can have kind signatures at
type variables introduced in the head. These signatures must be compatible
with the kinds inferred for the declaration of the associated data type. In
particular, if an AT definition has a variable-only parameter with a kind
signature, this signature must match the corresponding signature at the AT
declaration or the class declaration (if it is a class parameter). If there
is no signature, and hence, the variable's kind was inferred as being *, the
only signature allowed at the definition is *. Rationale: We need to allow
extra kind signatures, as type indexes may introduce new variables, which we
cannot annotate in any other way. Moreover, to keep the story simple, we
allow signatures at all variables and simply require that they are
compatible with the kinds inferred for declarations. NB: The definition is
such that there is never a need to propagate kind information from an AT
definition to the corresponding AT declaration or class declaration.
* The declaration of an associated data type in a class can have a deriving
clause. The meaning is that all instances of that type inherit all these
derivings (or do we merely want to force them to state - at least - these
derivings). Rationale: If I want equality on an associated type, I need to
guarantee that all its variants come with an equality.
Revision Changes Path
18.104.22.168 +1 -1 fptools/ghc/compiler/deSugar/DsMeta.hs
22.214.171.124 +11 -3 fptools/ghc/compiler/hsSyn/Convert.lhs
126.96.36.199 +42 -17 fptools/ghc/compiler/hsSyn/HsDecls.lhs
188.8.131.52 +1 -1 fptools/ghc/compiler/main/HscStats.lhs
184.108.40.206 +59 -18 fptools/ghc/compiler/parser/Parser.y.pp
220.127.116.11 +2 -2 fptools/ghc/compiler/parser/ParserCore.y
18.104.22.168 +117 -35 fptools/ghc/compiler/parser/RdrHsSyn.lhs
22.214.171.124 +1 -0 fptools/ghc/compiler/rename/RnBinds.lhs
126.96.36.199 +18 -2 fptools/ghc/compiler/rename/RnNames.lhs
188.8.131.52 +157 -20 fptools/ghc/compiler/rename/RnSource.lhs
184.108.40.206 +2 -1 fptools/ghc/compiler/typecheck/TcInstDcls.lhs
220.127.116.11 +6 -1 fptools/ghc/compiler/typecheck/TcRnMonad.lhs
18.104.22.168 +18 -3 fptools/ghc/compiler/typecheck/TcTyClsDecls.lhs
More information about the Cvs-ghc