on master help sign in
Support appendable types
commit3065f58924a951bf69405725727943133a88547d authorEvan Czaplicki <info@elm-lang.org> dateTue 30 Jul 2013, 08:58 (13 years ago) parentae6a3b3
1 file changed+11
compiler/Type/Unify.hs+11
compiler/Type/Unify.hs+11
@@ -97,6 +97,12 @@ actuallyUnify variable1 variable2 = do
9797 cmpVars <- liftIO $ forM [1..length vs] $ \_ -> var (Is Comparable)
9898 zipWithM_ unify vs cmpVars
9999
100+ unifyAppendable varSuper varFlex =
101+ do struct <- liftIO $ collectApps varFlex
102+ case struct of
103+ List _ -> flexAndUnify varSuper
104+ _ -> comparableError ""
105+
100106 superUnify =
101107 case (flex desc1, flex desc2, name desc1, name desc2) of
102108 (Is super1, Is super2, _, _)
@@ -112,6 +118,11 @@ actuallyUnify variable1 variable2 = do
112118 (Is Comparable, _, _, _) -> unifyComparableStructure variable1 variable2
113119 (_, Is Comparable, _, _) -> unifyComparableStructure variable2 variable1
114120
121+ (Is Appendable, _, _, Just "Text") -> flexAndUnify variable1
122+ (_, Is Appendable, Just "Text", _) -> flexAndUnify variable2
123+ (Is Appendable, _, _, _) -> unifyAppendable variable1 variable2
124+ (_, Is Appendable, _, _) -> unifyAppendable variable2 variable1
125+
115126 _ -> TS.addError "" variable1 variable2
116127
117128 case (structure desc1, structure desc2) of