on master help sign in
Correct error with type inference.
commit54edea782766c49b062bb73c5e28a6b21c444c5d authorevancz <info@elm-lang.org> dateSun 20 May 2012, 21:36 (14 years ago) parent617c7a9
1 file changed+14−13
src/Types/Unify.hs+14−13
src/Types/Unify.hs+14−13
@@ -11,17 +11,6 @@ import Types
1111
1212import Control.DeepSeq
1313
14−force x = x `deepseq` x
15−
16−instance NFData Constraint where
17− rnf (t1 :=: t2) = t1 `deepseq` t2 `deepseq` ()
18− rnf (t1 :<: t2) = t1 `deepseq` t2 `deepseq` ()
19−
20−instance NFData Type where
21− rnf (LambdaT t1 t2) = t1 `deepseq` t2 `deepseq` ()
22− rnf (ADT _ ts) = foldl' (\acc x -> x `deepseq` acc) () ts
23− rnf t = t `seq` ()
24−
2514unify hints expr = run $ do
2615 cs <- constrain hints expr
2716 solver cs []
@@ -49,7 +38,8 @@ solver ((t1 :=: t2) : cs) subs =
4938
5039solver ((t1 :<: t2) : cs) subs = do
5140 let f x = do y <- guid ; return (x,VarT y)
52− t2' <- foldl' (uncurry . flip tSub) t2 `liftM` (mapM f . Set.toList $ getVars t2)
41+ pairs <- mapM f . Set.toList $ getVars t2
42+ let t2' = foldr (uncurry tSub) t2 pairs
5343 solver ((t1 :=: t2') : cs) subs
5444
5545
@@ -67,4 +57,15 @@ getVars (ADT name ts) = Set.unions $ map getVars ts
6757getVars _ = Set.empty
6858
6959uniError t1 t2 =
70− return . Left $ "Type error: " ++ show t1 ++ " is not equal to " ++ show t2
60+ return . Left $ "Type error: " ++ show t1 ++ " is not equal to " ++ show t2
61+
62+force x = x `deepseq` x
63+
64+instance NFData Constraint where
65+ rnf (t1 :=: t2) = t1 `deepseq` t2 `deepseq` ()
66+ rnf (t1 :<: t2) = t1 `deepseq` t2 `deepseq` ()
67+
68+instance NFData Type where
69+ rnf (LambdaT t1 t2) = t1 `deepseq` t2 `deepseq` ()
70+ rnf (ADT _ ts) = foldl' (\acc x -> x `deepseq` acc) () ts
71+ rnf t = t `seq` ()