on master help sign in
Fix bug in `concretize` in which a fold uses the base for every step instead of accumulating the result (i.e. `t` becomes `t'`). One character mistakes are the worst! Let-polymorphism should be working for everything now! FINALLY! Mabye...
commitdea401b9f84a7848377740ccf29b2c34c88510e5 authorevancz <info@elm-lang.org> dateThu 9 Aug 2012, 18:18 (14 years ago) parent2f327b0
3 files changed+9−9
elm/src/Types/Constrain.hs+1−1 elm/src/Types/Substitutions.hs+4−4 elm/src/Types/Unify.hs+4−4
elm/src/Types/Constrain.hs+1−1
@@ -14,7 +14,7 @@ import Types.Substitutions
1414
1515--import System.IO.Unsafe
1616
17−prints xs v = v --unsafePerformIO (putStrLn "~~~~~~~~~~" >> mapM print xs) `seq` v
17+prints xs v = v --} unsafePerformIO (putStrLn "~~~~~~~~~~" >> mapM print xs) `seq` v
1818
1919beta = VarT `liftM` guid
2020unionA = Map.unionWith (++)
elm/src/Types/Substitutions.hs+4−4
@@ -69,15 +69,15 @@ cSubNoContext k v (x :<<: poly@(Forall vs cs tipe)) = force $ x :<<: poly'
6969
7070concretize (Forall xs cs t) = do
7171 pairs <- mapM (\x -> liftM ((,) x) guid) xs
72− return ( foldl' (\t' (k,v) -> tSub k (VarT v) t) t pairs
72+ return ( foldl' (\t' (k,v) -> tSub k (VarT v) t') t pairs
7373 , foldl' (\cs' (k,v) -> map (cSub k $ VarT v) cs') cs pairs )
7474
7575rescheme :: Scheme -> GuidCounter Scheme
7676rescheme (Forall xs cs t) = do
7777 pairs <- mapM (\x -> liftM ((,) x) guid) xs
78− let t' = foldl' (\t' (k,v) -> tSub k (VarT v) t') t pairs
79− let cs' = foldl' (\cs' (k,v) -> map (cSub k $ VarT v) cs') cs pairs
80− return $ Forall (map snd pairs) cs' t'
78+ let tipe = foldl' (\t' (k,v) -> tSub k (VarT v) t') t pairs
79+ let cs' = foldl' (\cs' (k,v) -> map (cSub k $ VarT v) cs') cs pairs
80+ return $ Forall (map snd pairs) cs' tipe
8181
8282freeVars (VarT v) = [v]
8383freeVars (LambdaT t1 t2) = freeVars t1 ++ freeVars t2
elm/src/Types/Unify.hs+4−4
@@ -13,8 +13,7 @@ import Types.Substitutions
1313
1414--import System.IO.Unsafe
1515
16−prints xs v = v --unsafePerformIO (putStrLn "----------" >> mapM print xs) `seq` v
17−prints' xs v = v --prints (Map.toList xs) v
16+prints xs v = v --} unsafePerformIO (putStrLn "----------" >> mapM print xs) `seq` v
1817
1918unify hints modul = run $ do
2019 cs <- constrain hints modul
@@ -91,10 +90,11 @@ solver (Context ctx (t :<: Super ts) : cs) subs
9190solver (Context ctx (x :<<: s) : cs) subs
9291 | any (\(Context _ c) -> x `elem` cFreeVars c) cs =
9392 do cs' <- concat `liftM` mapM (schemeSub x s) cs
94− solver cs' subs
93+ prints cs' $ solver cs' subs
9594 | otherwise =
9695 do (t,cs') <- concretize s
97− solver (Context ctx (VarT x :=: t) : map (extendCtx ctx) cs' ++ cs) subs
96+ let cs'' = (cs ++ Context ctx (VarT x :=: t) : map (extendCtx ctx) cs')
97+ prints cs'' $ solver cs'' subs
9898
9999
100100uniError ctx t1 t2 =