diff --git a/src/IL/Typing.hs b/src/IL/Typing.hs index 3e3233096cee690aac01d3526afa974ff7837d64..9208275caf04919cee3d08386ca488e80fa5f46d 100644 --- a/src/IL/Typing.hs +++ b/src/IL/Typing.hs @@ -11,12 +11,23 @@ TODO -} -module IL.Typing (Typeable(..)) where +module IL.Typing (Typeable(..), prenexType) where import Base.Messages (internalError) import IL.Type +-- | Converts the given type into prenex form. +prenexType :: Type -> Type +prenexType (TypeConstructor tc tys) = TypeConstructor tc $ map prenexType tys +prenexType tv@(TypeVariable _) = tv +prenexType (TypeArrow ty1 ty2) = case prenexType ty2 of + TypeForall tvs ty2' -> TypeForall tvs $ TypeArrow (prenexType ty1) ty2' + ty2' -> TypeArrow (prenexType ty1) ty2' +prenexType (TypeForall tvs ty) = case prenexType ty of + TypeForall tvs' ty' -> TypeForall (tvs ++ tvs') ty' + ty' -> TypeForall tvs ty' + class Typeable a where typeOf :: a -> Type diff --git a/src/Transformations/CurryToIL.hs b/src/Transformations/CurryToIL.hs index d401933d4de00d499679b46cafdf3da2d394c1a3..67794cb234f8bbee3fe4492577e7377e961564cd 100644 --- a/src/Transformations/CurryToIL.hs +++ b/src/Transformations/CurryToIL.hs @@ -213,7 +213,7 @@ trExternal (Var ty f) = do -- type constructors. transType :: TCEnv -> Type -> IL.Type -transType tcEnv ty' = transType' ty' [] +transType tcEnv ty' = IL.prenexType $ transType' ty' [] where ks = transTVars tcEnv ty' transType' (TypeConstructor tc) = IL.TypeConstructor tc