diff --git a/src/Base/TypeSubst.hs b/src/Base/TypeSubst.hs index fb39c8f97907dbfd0e3752d0756ab1bcb92d68a4..c1e9d3dc0158c459470eac9b4bbb9252c50a9ce1 100644 --- a/src/Base/TypeSubst.hs +++ b/src/Base/TypeSubst.hs @@ -45,11 +45,11 @@ instance SubstType Type where subst sigma (TypeArrow ty1 ty2) = TypeArrow (subst sigma ty1) (subst sigma ty2) subst _ ts@(TypeSkolem _) = ts - subst sigma (TypeRecord fs rv) - | isJust rv = case substVar sigma (fromJust rv) of - TypeVariable tv -> TypeRecord fs' (Just tv) - ty -> ty - | otherwise = TypeRecord fs' Nothing + subst sigma (TypeRecord fs rv) = case rv of + Nothing -> TypeRecord fs' Nothing + Just r' -> case substVar sigma r' of + TypeVariable tv -> TypeRecord fs' (Just tv) + ty -> ty where fs' = map (\ (l,ty) -> (l, subst sigma ty)) fs instance SubstType TypeScheme where @@ -80,19 +80,17 @@ instance SubstType a => SubstType (TopEnv a) where expandAliasType :: [Type] -> Type -> Type expandAliasType tys (TypeConstructor tc tys') = TypeConstructor tc (map (expandAliasType tys) tys') -expandAliasType tys (TypeVariable n) +expandAliasType tys (TypeVariable n) | n >= 0 = tys !! n | otherwise = TypeVariable n expandAliasType _ (TypeConstrained tys n) = TypeConstrained tys n expandAliasType tys (TypeArrow ty1 ty2) = TypeArrow (expandAliasType tys ty1) (expandAliasType tys ty2) expandAliasType _ tsk@(TypeSkolem _) = tsk -expandAliasType tys (TypeRecord fs rv) - | isJust rv = - let (TypeVariable tv) = expandAliasType tys $ TypeVariable $ fromJust rv - in TypeRecord fs' (Just tv) - | otherwise = - TypeRecord fs' Nothing +expandAliasType tys (TypeRecord fs rv) = case rv of + Nothing -> TypeRecord fs' Nothing + Just r' -> let (TypeVariable tv) = expandAliasType tys $ TypeVariable r' + in TypeRecord fs' (Just tv) where fs' = map (\ (l, ty) -> (l, expandAliasType tys ty)) fs normalize :: Type -> Type diff --git a/src/Transformations/Desugar.hs b/src/Transformations/Desugar.hs index 3b21eeb20edfdbd1dcbb6f7792df74514e711374..0d668a281fc5ec10a3987a847f63e8e401482706 100644 --- a/src/Transformations/Desugar.hs +++ b/src/Transformations/Desugar.hs @@ -36,7 +36,7 @@ - let expressions, and - case expressions. - * Applications 'N:x' in patterns and expressions, where 'N' is a + * Applications 'N x' in patterns and expressions, where 'N' is a newtype constructor, are replaced by a 'x'. Note that neither the newtype declaration itself nor partial applications of newtype constructors are changed (It were possible to replace partial @@ -44,7 +44,7 @@ However, our solution yields a more accurate output when the result of a computation includes partial applications.). - * Function patterns are replaced by variables and are integrated + * Functional patterns are replaced by variables and are integrated in a guarded right hand side using the (=:<=) operator * Records, which currently must be declared using the keyword diff --git a/test/DefaultPrecedence.curry b/test/DefaultPrecedence.curry new file mode 100644 index 0000000000000000000000000000000000000000..a8ef8ac22af5ef990479a5929f51e8e0e5e012c6 --- /dev/null +++ b/test/DefaultPrecedence.curry @@ -0,0 +1,3 @@ +-- infixr 9 <$> + +f <$> x = f x \ No newline at end of file diff --git a/test/TypedExpr.curry b/test/TypedExpr.curry new file mode 100644 index 0000000000000000000000000000000000000000..bda70a0fb6d4db396f3e746ea935af1566d1b8dc --- /dev/null +++ b/test/TypedExpr.curry @@ -0,0 +1,2 @@ +s :: String +s = "hallo" :: String