git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #195 from garyb/master
dfa5117Phil Freeman
src/Language/PureScript/Pretty/Types.hs+6−3
@@ -32,7 +32,7 @@ import Language.PureScript.Pretty.Common
32typeLiterals :: Pattern () Type String
32typeLiterals :: Pattern () Type String
33typeLiterals = mkPattern match
33typeLiterals = mkPattern match
34 where
34 where
35− match (Object row) = Just $ "{ " ++ prettyPrintType row ++ " }"
35+ match (Object row) = Just $ "{ " ++ prettyPrintObjectRow row ++ " }"
36 match (TypeVar var) = Just var
36 match (TypeVar var) = Just var
37 match (PrettyPrintArray ty) = Just $ "[" ++ prettyPrintType ty ++ "]"
37 match (PrettyPrintArray ty) = Just $ "[" ++ prettyPrintType ty ++ "]"
38 match ty@(TypeConstructor ctor) = Just $ show ctor
38 match ty@(TypeConstructor ctor) = Just $ show ctor
@@ -41,9 +41,12 @@ typeLiterals = mkPattern match
41 match (ConstrainedType deps ty) = Just $ "(" ++ intercalate "," (map (\(pn, ty') -> show pn ++ " (" ++ prettyPrintType ty' ++ ")") deps) ++ ") => " ++ prettyPrintType ty
41 match (ConstrainedType deps ty) = Just $ "(" ++ intercalate "," (map (\(pn, ty') -> show pn ++ " (" ++ prettyPrintType ty' ++ ")") deps) ++ ") => " ++ prettyPrintType ty
42 match (SaturatedTypeSynonym name args) = Just $ show name ++ "<" ++ intercalate "," (map prettyPrintType args) ++ ">"
42 match (SaturatedTypeSynonym name args) = Just $ show name ++ "<" ++ intercalate "," (map prettyPrintType args) ++ ">"
43 match (ForAll ident ty _) = Just $ "forall " ++ ident ++ ". " ++ prettyPrintType ty
43 match (ForAll ident ty _) = Just $ "forall " ++ ident ++ ". " ++ prettyPrintType ty
44− match REmpty = Just $ prettyPrintRow REmpty
44+ match REmpty = Just $ "()"
45− match row@(RCons _ _ _) = Just $ prettyPrintRow row
45+ match row@(RCons _ _ _) = Just $ '(' : prettyPrintRow row ++ ")"
46 match _ = Nothing
46 match _ = Nothing
47+ prettyPrintObjectRow REmpty = ""
48+ prettyPrintObjectRow row@(RCons _ _ _) = prettyPrintRow row
49+ prettyPrintObjectRow _ = error "Non-row type in Object"
47
50
48-- |
51-- |
49-- Generate a pretty-printed string representing a Row
52-- Generate a pretty-printed string representing a Row
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -152,7 +152,7 @@ unifyRows r1 r2 =
152 unifyRows' [] REmpty [] REmpty = return ()
152 unifyRows' [] REmpty [] REmpty = return ()
153 unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
153 unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
154 unifyRows' [] (Skolem s1 _) [] (Skolem s2 _) | s1 == s2 = return ()
154 unifyRows' [] (Skolem s1 _) [] (Skolem s2 _) | s1 == s2 = return ()
155− unifyRows' sd3 r3 sd4 r4 = throwError $ "Cannot unify " ++ prettyPrintRow (rowFromList (sd3, r3)) ++ " with " ++ prettyPrintRow (rowFromList (sd4, r4)) ++ "."
155+ unifyRows' sd3 r3 sd4 r4 = throwError $ "Cannot unify (" ++ prettyPrintRow (rowFromList (sd3, r3)) ++ ") with (" ++ prettyPrintRow (rowFromList (sd4, r4)) ++ ")."
156
156
157-- |
157-- |
158-- Ensure type constructors are equal after canonicalization
158-- Ensure type constructors are equal after canonicalization