\begin{code}
module IfaceType (
- IfaceType(..), IfaceKind(..), IfacePredType(..), IfaceTyCon(..),
+ IfaceType(..), IfaceKind, IfacePredType(..), IfaceTyCon(..),
IfaceContext, IfaceBndr(..), IfaceTvBndr, IfaceIdBndr,
IfaceExtName(..), mkIfaceExtName, ifaceTyConName,
-- Conversion from Type -> IfaceType
- toIfaceType, toIfaceKind, toIfacePred, toIfaceContext,
+ toIfaceType, toIfacePred, toIfaceContext,
toIfaceBndr, toIfaceIdBndr, toIfaceTvBndrs,
-- Printing
- pprIfaceKind, pprParendIfaceKind,
pprIfaceType, pprParendIfaceType, pprIfaceContext,
pprIfaceIdBndr, pprIfaceTvBndr, pprIfaceTvBndrs, pprIfaceBndrs,
getIfaceExt,
#include "HsVersions.h"
-import Type ( openTypeKind, liftedTypeKind, unliftedTypeKind,
- splitFunTy_maybe, eqKind )
+import Kind ( Kind(..) )
import TypeRep ( Type(..), TyNote(..), PredType(..), Kind, ThetaType )
import TyCon ( TyCon, isTupleTyCon, tyConArity, tupleTyConBoxity )
import Var ( isId, tyVarKind, idType )
import BasicTypes ( IPName(..), Arity, Version, mapIPName, tupleParens, Boxity )
import Outputable
import FastString
-
-#ifdef DEBUG
-import TypeRep( crudePprType )
-#endif
\end{code}
type IfaceTvBndr = (OccName, IfaceKind)
-------------------------------
-data IfaceKind
- = IfaceLiftedTypeKind
- | IfaceOpenTypeKind
- | IfaceUnliftedTypeKind
- | IfaceFunKind IfaceKind IfaceKind
- deriving( Eq )
+type IfaceKind = Kind -- Re-use the Kind type, but no KindVars in it
--------------------------------
data IfaceType
= IfaceTyVar OccName -- Type variable only, not tycon
| IfaceAppTy IfaceType IfaceType
pprIfaceIdBndr (name, ty) = hsep [ppr name, dcolon, ppr ty]
pprIfaceTvBndr :: IfaceTvBndr -> SDoc
-pprIfaceTvBndr (tv, IfaceLiftedTypeKind) = ppr tv
-pprIfaceTvBndr (tv, kind) = parens (ppr tv <> dcolon <> ppr kind)
+pprIfaceTvBndr (tv, LiftedTypeKind) = ppr tv
+pprIfaceTvBndr (tv, kind) = parens (ppr tv <> dcolon <> ppr kind)
pprIfaceTvBndrs :: [IfaceTvBndr] -> SDoc
pprIfaceTvBndrs tyvars = hsep (map pprIfaceTvBndr tyvars)
\begin{code}
---------------------------------
-instance Outputable IfaceKind where
- ppr k = pprIfaceKind tOP_PREC k
-
-pprParendIfaceKind :: IfaceKind -> SDoc
-pprParendIfaceKind k = pprIfaceKind tYCON_PREC k
-
-pprIfaceKind prec IfaceLiftedTypeKind = ptext SLIT("*")
-pprIfaceKind prec IfaceUnliftedTypeKind = ptext SLIT("#")
-pprIfaceKind prec IfaceOpenTypeKind = ptext SLIT("?")
-pprIfaceKind prec (IfaceFunKind k1 k2) = maybeParen prec fUN_PREC $
- sep [ pprIfaceKind fUN_PREC k1, arrow <+> ppr k2]
-
----------------------------------
instance Outputable IfaceType where
ppr ty = ppr_ty ty
-- Simple cases
pprIfaceType ctxt_prec (IfaceTyVar tyvar) = ppr tyvar
pprIfaceType ctxt_prec (IfaceTyConApp tc tys) = ppr_tc_app ctxt_prec tc tys
-pprIfaceType ctxt_prec (IfacePredTy st) = braces (ppr st)
+pprIfaceType ctxt_prec (IfacePredTy st) = braces (ppr st)
-- Function types
pprIfaceType ctxt_prec (IfaceFunTy ty1 ty2)
\begin{code}
----------------
-toIfaceTvBndr tyvar = (getOccName tyvar, toIfaceKind (tyVarKind tyvar))
+toIfaceTvBndr tyvar = (getOccName tyvar, tyVarKind tyvar)
toIfaceIdBndr ext id = (getOccName id, toIfaceType ext (idType id))
toIfaceTvBndrs tyvars = map toIfaceTvBndr tyvars
| otherwise = IfaceTvBndr (toIfaceTvBndr var)
---------------------
-toIfaceKind :: Kind -> IfaceKind
-toIfaceKind k
- | k `eqKind` openTypeKind = IfaceOpenTypeKind
- | k `eqKind` liftedTypeKind = IfaceLiftedTypeKind
- | k `eqKind` unliftedTypeKind = IfaceUnliftedTypeKind
- | Just (arg,res) <- splitFunTy_maybe k
- = IfaceFunKind (toIfaceKind arg) (toIfaceKind res)
-#ifdef DEBUG
- | otherwise = pprPanic "toIfaceKind" (crudePprType k)
-#endif
-
----------------------
toIfaceType :: (Name -> IfaceExtName) -> Type -> IfaceType
toIfaceType ext (TyVarTy tv) = IfaceTyVar (getOccName tv)
toIfaceType ext (AppTy t1 t2) = IfaceAppTy (toIfaceType ext t1) (toIfaceType ext t2)