openKindCon, -- :: KX
typeCon, -- :: BX -> KX
liftedTypeKind, unliftedTypeKind, openTypeKind, -- :: KX
+ isLiftedTypeKind, isUnliftedTypeKind, isOpenTypeKind, isSuperKind,
mkArrowKind, mkArrowKinds, -- :: KX -> KX -> KX
isTypeKind, isAnyTypeKind,
funTyCon,
applyTy, applyTys, isForAllTy, dropForAlls,
-- Source types
- isPredTy, predTypeRep, mkPredTy, mkPredTys,
+ predTypeRep, mkPredTy, mkPredTys,
-- Newtypes
splitRecNewType_maybe,
eqType, eqKind,
-- Seq
- seqType, seqTypes
+ seqType, seqTypes,
+ -- Pretty-printing
+ pprKind, pprParendKind,
+ pprType, pprParendType,
+ pprPred, pprTheta, pprThetaArrow, pprClassPred
) where
#include "HsVersions.h"
\begin{code}
mkAppTy orig_ty1 orig_ty2
- = ASSERT2( not (isPredTy orig_ty1), crudePprType orig_ty1 ) -- Source types are of kind *
- mk_app orig_ty1
+ = mk_app orig_ty1
where
mk_app (NoteTy _ ty1) = mk_app ty1
mk_app (NewTcApp tc tys) = NewTcApp tc (tys ++ [orig_ty2])
-- returns to (Ratio Integer), which has needlessly lost
-- the Rational part.
mkAppTys orig_ty1 orig_tys2
- = ASSERT( not (isPredTy orig_ty1) ) -- Source types are of kind *
- mk_app orig_ty1
+ = mk_app orig_ty1
where
mk_app (NoteTy _ ty1) = mk_app ty1
mk_app (NewTcApp tc tys) = NewTcApp tc (tys ++ orig_tys2)
splitFunTy (NoteTy _ ty) = splitFunTy ty
splitFunTy (PredTy p) = splitFunTy (predTypeRep p)
splitFunTy (NewTcApp tc tys) = splitFunTy (newTypeRep tc tys)
-splitFunTy other = pprPanic "splitFunTy" (crudePprType other)
+splitFunTy other = pprPanic "splitFunTy" (ppr other)
splitFunTy_maybe :: Type -> Maybe (Type, Type)
splitFunTy_maybe (FunTy arg res) = Just (arg, res)
split acc xs nty (NoteTy _ ty) = split acc xs nty ty
split acc xs nty (PredTy p) = split acc xs nty (predTypeRep p)
split acc xs nty (NewTcApp tc tys) = split acc xs nty (newTypeRep tc tys)
- split acc (x:xs) nty ty = pprPanic "zipFunTys" (ppr orig_xs <+> crudePprType orig_ty)
+ split acc (x:xs) nty ty = pprPanic "zipFunTys" (ppr orig_xs <+> ppr orig_ty)
funResultTy :: Type -> Type
funResultTy (FunTy arg res) = res
funResultTy (NoteTy _ ty) = funResultTy ty
funResultTy (PredTy p) = funResultTy (predTypeRep p)
funResultTy (NewTcApp tc tys) = funResultTy (newTypeRep tc tys)
-funResultTy ty = pprPanic "funResultTy" (crudePprType ty)
+funResultTy ty = pprPanic "funResultTy" (ppr ty)
funArgTy :: Type -> Type
funArgTy (FunTy arg res) = arg
funArgTy (NoteTy _ ty) = funArgTy ty
funArgTy (PredTy p) = funArgTy (predTypeRep p)
funArgTy (NewTcApp tc tys) = funArgTy (newTypeRep tc tys)
-funArgTy ty = pprPanic "funArgTy" (crudePprType ty)
+funArgTy ty = pprPanic "funArgTy" (ppr ty)
\end{code}
splitTyConApp :: Type -> (TyCon, [Type])
splitTyConApp ty = case splitTyConApp_maybe ty of
Just stuff -> stuff
- Nothing -> pprPanic "splitTyConApp" (crudePprType ty)
+ Nothing -> pprPanic "splitTyConApp" (ppr ty)
splitTyConApp_maybe :: Type -> Maybe (TyCon, [Type])
splitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys)
FunTy _ _ -> PtrRep
AppTy _ _ -> PtrRep -- ??
TyVarTy _ -> PtrRep
- other -> pprPanic "typePrimRep" (crudePprType ty)
+ other -> pprPanic "typePrimRep" (ppr ty)
\end{code}
= substTyWith (take n_args tvs) arg_tys
(mkForAllTys (drop n_args tvs) rho_ty)
| otherwise -- Too many type args
- = ASSERT2( n_tvs > 0, crudePprType orig_fun_ty ) -- Zero case gives infnite loop!
+ = ASSERT2( n_tvs > 0, ppr orig_fun_ty ) -- Zero case gives infnite loop!
applyTys (substTyWith tvs (take n_tvs arg_tys) rho_ty)
(drop n_tvs arg_tys)
where
predTypeRep (ClassP clas tys) = mkTyConApp (classTyCon clas) tys
-- Result might be a NewTcApp, but the consumer will
-- look through that too if necessary
-
-isPredTy :: Type -> Bool
-isPredTy (NoteTy _ ty) = isPredTy ty
-isPredTy (PredTy sty) = True
-isPredTy _ = False
\end{code}