This repository was archived by the owner on Oct 18, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 11name : amuletml
2- version : 0.1 .0.0
2+ version : 0.2 .0.0
33synopsis : A functional programming language
44homepage : https://amulet.ml
55license : BSD3
Original file line number Diff line number Diff line change @@ -655,15 +655,27 @@ unify scope (TyOperator l v r) (TyOperator l' v' r')
655655
656656unify scope ta@ (TyApps (TyCon v) xs@ (_: _)) b = do
657657 x <- view solveInfo
658+ traceM (show (x ^. at v))
658659 case x ^. at v of
659660 Just (Right tf) -> unifyTyFunApp tf scope xs b
660661 _ -> case b of
662+ TyApps (TyCon v) ys | Just (Right tf) <- x ^. at v -> SymCo <$> unify scope b ta
663+
661664 TyApps f ys | length xs == length ys -> rethrow ta b $ do
662665 heads <- unify scope (TyCon v) f
663666 tails <- traverse (uncurry (unify scope)) (zip xs ys)
664667 pure (foldl AppCo heads tails)
668+
665669 TyApps f ys | length ys < length xs -> rethrow ta b $ do
666- let (xs_a, xs_b) = splitAt (length ys) xs
670+ case f of
671+ TyCon {} -> confesses =<< unequal ta b
672+ _ -> pure ()
673+
674+ let ys_l = length ys
675+ xs_l = length xs
676+ xs_a = take (xs_l - ys_l) xs
677+ xs_b = drop (xs_l - ys_l) xs
678+
667679 heads <- unify scope (TyApps (TyCon v) xs_a) f
668680 tails <- traverse (uncurry (unify scope)) (zip xs_b ys)
669681 pure (foldl AppCo heads tails)
@@ -675,7 +687,6 @@ unify scope a tb@(TyApps (TyCon _) (_:_)) = rethrow a tb $ SymCo <$> unify scope
675687
676688unify scope (TyApp f x) (TyApp g y) = AppCo <$> unify scope f g <*> unify scope x y
677689
678-
679690unify _ TyType TyType = pure (ReflCo TyType )
680691unify _ a b = confesses =<< unequal a b -- }}}
681692
Original file line number Diff line number Diff line change 1+ type sum 'f 'g 'a =
2+ | L1 of 'f 'a
3+
4+ type k1 'c 'a = K1 of 'c
5+ type m1 'f 'a = M1 of 'f 'a
6+
7+ let f x = M1 (L1 (M1 (K1 x)))
8+
9+ let _ = f 123
Original file line number Diff line number Diff line change 1+ sum : Infer{'a : type}. Infer{'b : type}. ('b -> type) -> 'a -> 'b -> type
2+ L1 : Spec{'f : 'b -> type}. Spec{'g : 'a}. Spec{'a : 'b}. 'f 'a -> sum 'f 'g 'a
3+ k1 : Infer{'a : type}. type -> 'a -> type
4+ K1 : Spec{'c : type}. Spec{'a : 'a}. 'c -> k1 'c 'a
5+ m1 : Infer{'a : type}. ('a -> type) -> 'a -> type
6+ M1 : Spec{'f : 'a -> type}. Spec{'a : 'a}. 'f 'a -> m1 'f 'a
7+ f : Infer{'a : type}. Infer{'b : 'a}. Infer{'g : 'a}. 'a -> m1 (sum (m1 (k1 'a)) 'g) 'b
You can’t perform that action at this time.
0 commit comments