diff options
author | Jose Pedro Magalhaes <jpm@cs.uu.nl> | 2011-11-16 18:08:32 +0000 |
---|---|---|
committer | Jose Pedro Magalhaes <jpm@cs.uu.nl> | 2011-11-16 20:47:11 +0100 |
commit | 2da8a4d1139978db997fc1a4b6690cad5996b536 (patch) | |
tree | 0287aaa9bbe45f5cb9420ccb1c777baa842102a1 /compiler/types | |
parent | e589a49d8edd8b106d1a8396943466977ceeac0c (diff) | |
download | haskell-2da8a4d1139978db997fc1a4b6690cad5996b536.tar.gz |
Move mkPiTypes back to Type, rename mkForAllArrowKinds to mkPiKinds
Diffstat (limited to 'compiler/types')
-rw-r--r-- | compiler/types/Type.lhs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index cb253d82fc..a29e9415d7 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -39,7 +39,7 @@ module Type ( splitTyConApp_maybe, splitTyConApp, mkForAllTy, mkForAllTys, splitForAllTy_maybe, splitForAllTys, - mkForAllArrowKinds, + mkPiKinds, mkPiType, mkPiTypes, applyTy, applyTys, applyTysD, isForAllTy, dropForAlls, -- (Newtypes) @@ -675,12 +675,25 @@ mkForAllTy tyvar ty mkForAllTys :: [TyVar] -> Type -> Type mkForAllTys tyvars ty = foldr ForAllTy ty tyvars -mkForAllArrowKinds :: [TyVar] -> Kind -> Kind --- mkForAllArrowKinds [k1, k2, (a:k1 -> *)] k2 +mkPiKinds :: [TyVar] -> Kind -> Kind +-- mkPiKinds [k1, k2, (a:k1 -> *)] k2 -- returns forall k1 k2. (k1 -> *) -> k2 -mkForAllArrowKinds ktvs res = - mkForAllTys kvs $ mkArrowKinds (map tyVarKind tvs) res - where (kvs, tvs) = splitKiTyVars ktvs +mkPiKinds [] res = res +mkPiKinds (tv:tvs) res + | isKiVar tv = ForAllTy tv (mkPiKinds tvs res) + | otherwise = FunTy (tyVarKind tv) (mkPiKinds tvs res) + +mkPiType :: Var -> Type -> Type +-- ^ Makes a @(->)@ type or a forall type, depending +-- on whether it is given a type variable or a term variable. +mkPiTypes :: [Var] -> Type -> Type +-- ^ 'mkPiType' for multiple type or value arguments + +mkPiType v ty + | isId v = mkFunTy (varType v) ty + | otherwise = mkForAllTy v ty + +mkPiTypes vs ty = foldr mkPiType ty vs isForAllTy :: Type -> Bool isForAllTy (ForAllTy _ _) = True |