-
-\end{code}
-
-%************************************************************************
-%* *
-\subsection{Type Classifications}
-%* *
-%************************************************************************
-
-A type is
-
- *unboxed* iff its representation is other than a pointer
- Unboxed types cannot instantiate a type variable
- Unboxed types are always unlifted.
-
- *lifted* A type is lifted iff it has bottom as an element.
- Closures always have lifted types: i.e. any
- let-bound identifier in Core must have a lifted
- type. Operationally, a lifted object is one that
- can be entered.
- (NOTE: previously "pointed").
-
- *algebraic* A type with one or more constructors. An algebraic
- type is one that can be deconstructed with a case
- expression. *NOT* the same as lifted types,
- because we also include unboxed tuples in this
- classification.
-
- *primitive* iff it is a built-in type that can't be expressed
- in Haskell.
-
-Currently, all primitive types are unlifted, but that's not necessarily
-the case. (E.g. Int could be primitive.)
-
-Some primitive types are unboxed, such as Int#, whereas some are boxed
-but unlifted (such as ByteArray#). The only primitive types that we
-classify as algebraic are the unboxed tuples.
-
-examples of type classifications:
-
-Type primitive boxed lifted algebraic
------------------------------------------------------------------------------
-Int#, Yes No No No
-ByteArray# Yes Yes No No
-(# a, b #) Yes No No Yes
-( a, b ) No Yes Yes Yes
-[a] No Yes Yes Yes
-
-%************************************************************************
-%* *
-\subsection{The data type}
-%* *
-%************************************************************************
-
-
-\begin{code}
-type Type = GenType Unused -- Used after typechecker
-
-type GenKind flexi = GenType flexi
-type Kind = Type
-
-type TyVarSubst = TyVarEnv Type
-type GenTyVarSubst flexi = TyVarEnv (GenType flexi)
-
-data GenType flexi -- Parameterised over the "flexi" part of a type variable
- = TyVarTy (GenTyVar flexi)
-
- | AppTy
- (GenType flexi) -- Function is *not* a TyConApp
- (GenType flexi)
-
- | TyConApp -- Application of a TyCon
- TyCon -- *Invariant* saturated appliations of FunTyCon and
- -- synonyms have their own constructors, below.
- [GenType flexi] -- Might not be saturated.
-
- | FunTy -- Special case of TyConApp: TyConApp FunTyCon [t1,t2]
- (GenType flexi)
- (GenType flexi)
-
- | NoteTy -- Saturated application of a type synonym
- (TyNote flexi)
- (GenType flexi) -- The expanded version
-
- | ForAllTy
- (GenTyVar flexi)
- (GenType flexi) -- TypeKind
-
-data TyNote flexi
- = SynNote (GenType flexi) -- The unexpanded version of the type synonym; always a TyConApp
- | FTVNote (GenTyVarSet flexi) -- The free type variables of the noted expression