curry-frontend-1.0.4: Compile the functional logic language Curry to several intermediate formats

Copyright(c) 2002 - 2004 Wolfgang Lux
2011 Björn Peemöller
2016 Finn Teegen
Safe HaskellNone



For all defined types the compiler must maintain kind information. For algebraic data types and renaming types the compiler also records all data constructors belonging to that type, for alias types the type expression to be expanded is saved. Futhermore, recording the arity is necessary for alias types because the right hand side, i.e., the type expression, can have arbitrary kind and therefore the type alias' arity cannot be determined from its own kind. For instance, the type alias type List = [] has the kind * -> *, but its arity is 0. In order to manage the import and export of types, the names of the original definitions are also recorded. On import two types are considered equal if their original names match.

The information for a data constructor comprises the number of existentially quantified type variables, the context and the list of the argument types. Note that renaming type constructors have only one type argument.

For type classes the all their methods are saved. Type classes are recorded in the type constructor environment because type constructors and type classes share a common name space.

For type variables only their kind is recorded in the environment.

Importing and exporting algebraic data types and renaming types is complicated by the fact that the constructors of the type may be (partially) hidden in the interface. This facilitates the definition of abstract data types. An abstract type is always represented as a data type without constructors in the interface regardless of whether it is defined as a data type or as a renaming type. When only some constructors of a data type are hidden, those constructors are replaced by underscores in the interface. Furthermore, if the right-most constructors of a data type are hidden, they are not exported at all in order to make the interface more stable against changes which are private to the module.