@@ -34,7 +34,7 @@ data UResult a = UOK a
3434match_unify :: Context -> Env -> TT Name -> TT Name -> [Name] -> [Name] ->
3535 TC [(Name, TT Name)]
3636match_unify ctxt env topx topy dont holes =
37−-- trace ("Matching " ++ show (topx, topy)) $
37+-- trace ("Matching " ++ show (topx, topy)) $
3838 case runStateT (un [] topx topy) (UI 0 []) of
3939 OK (v, UI _ []) -> return (filter notTrivial v)
4040 res ->
@@ -56,6 +56,10 @@ match_unify ctxt env topx topy dont holes =
5656 | fst (bnames!!i) == x || snd (bnames!!i) == x = do sc 1; return []
5757 un bnames (P _ x _) (V i)
5858 | fst (bnames!!i) == x || snd (bnames!!i) == x = do sc 1; return []
59+ un bnames (Bind x bx sx) (Bind y by sy)
60+ = do h1 <- uB bnames bx by
61+ h2 <- un ((x, y) : bnames) sx sy
62+ combine bnames h1 h2
5963 un names (App fx ax) (App fy ay)
6064 = do hf <- un names fx fy
6165 ha <- un names ax ay
@@ -71,6 +75,19 @@ match_unify ctxt env topx topy dont holes =
7175 lift $ tfail err
7276
7377
78+ uB bnames (Let tx vx) (Let ty vy) = do h1 <- un bnames tx ty
79+ h2 <- un bnames vx vy
80+ combine bnames h1 h2
81+ uB bnames (Lam tx) (Lam ty) = un bnames tx ty
82+ uB bnames (Pi tx) (Pi ty) = un bnames tx ty
83+ uB bnames x y = do UI s f <- get
84+ let r = recoverable (binderTy x) (binderTy y)
85+ let err = CantUnify r topx topy
86+ (CantUnify r (binderTy x) (binderTy y) (Msg "") [] s)
87+ (errEnv env) s
88+ put (UI s ((binderTy x, binderTy y, env, err) : f))
89+ return []
90+
7491 -- TODO: there's an annoying amount of repetition between this and the
7592 -- main unification function. Consider lifting it out.
7693
@@ -391,12 +408,12 @@ unify ctxt env topx topy dont holes =
391408
392409 uB bnames (Let tx vx) (Let ty vy)
393410 = do h1 <- un' False bnames tx ty
394− h2 <- un' False bnames ty vy
411+ h2 <- un' False bnames vx vy
395412 sc 1
396413 combine bnames h1 h2
397414 uB bnames (Guess tx vx) (Guess ty vy)
398415 = do h1 <- un' False bnames tx ty
399− h2 <- un' False bnames ty vy
416+ h2 <- un' False bnames vx vy
400417 sc 1
401418 combine bnames h1 h2
402419 uB bnames (Lam tx) (Lam ty) = do sc 1; un' False bnames tx ty