-toHsTyVar :: TyVar -> HsTyVarBndr RdrName
-toHsTyVar tv = IfaceTyVar (toRdrName tv) (tyVarKind tv)
-
-toHsTyVars tvs = map toHsTyVar tvs
-
-toHsType :: Type -> HsType RdrName
-toHsType ty = toHsType' (unUsgTy ty)
- -- For now we just discard the usage
--- = case splitUsgTy ty of
--- (usg, tau) -> HsUsgTy (toHsUsg usg) (toHsType' tau)
-
-toHsType' :: Type -> HsType RdrName
--- Called after the usage is stripped off
--- This function knows the representation of types
-toHsType' (TyVarTy tv) = HsTyVar (toRdrName tv)
-toHsType' (FunTy arg res) = HsFunTy (toHsType arg) (toHsType res)
-toHsType' (AppTy fun arg) = HsAppTy (toHsType fun) (toHsType arg)
-
-toHsType' (NoteTy (SynNote ty) _) = toHsType ty -- Use synonyms if possible!!
-toHsType' (NoteTy _ ty) = toHsType ty
-
-toHsType' ty@(TyConApp tc tys) -- Must be saturated because toHsType's arg is of kind *
- | not saturated = generic_case
- | isTupleTyCon tc = HsTupleTy (HsTupCon (toRdrName tc) (tupleTyConBoxity tc)) tys'
- | tc `hasKey` listTyConKey = HsListTy (head tys')
- | maybeToBool maybe_class = HsPredTy (HsPClass (toRdrName clas) tys')
- | otherwise = generic_case
- where
- generic_case = foldl HsAppTy (HsTyVar (toRdrName tc)) tys'
- maybe_class = tyConClass_maybe tc
- Just clas = maybe_class
- tys' = map toHsType tys
- saturated = length tys == tyConArity tc
-
-toHsType' ty@(ForAllTy _ _) = case splitSigmaTy ty of
- (tvs, preds, tau) -> HsForAllTy (Just (map toHsTyVar tvs))
- (map toHsPred preds)
- (toHsType tau)
-
-
-toHsPred (Class cls tys) = HsPClass (toRdrName cls) (map toHsType tys)
-toHsPred (IParam n ty) = HsPIParam (toRdrName n) (toHsType ty)