@@ -303,11 +303,17 @@ unify ctxt env (topx, xfrom) (topy, yfrom) inj holes usersupp from =
303303
304304 injective (P (DCon _ _ _) _ _) = True
305305 injective (P (TCon _ _) _ _) = True
306− injective (P Ref n _)
307− | Just i <- lookupInjectiveExact n ctxt = i
306+-- injective (P Ref n _)
307+-- | Just i <- lookupInjectiveExact n ctxt = i
308308 injective (App _ f a) = injective f -- && injective a
309309 injective _ = False
310310
311+-- injectiveTC (P Ref n _) (P Ref n' _)
312+-- | Just i <- lookupInjectiveExact n ctxt,
313+-- n == n' = i
314+-- injectiveTC (App _ f a) (App _ f' a') = injectiveTC f a
315+-- injectiveTC _ _ = False
316+
311317-- injectiveVar (P _ (MN _ _) _) = True -- TMP HACK
312318 injectiveVar (P _ n _) = n `elem` inj
313319 injectiveVar (App _ f a) = injectiveVar f -- && injective a
@@ -534,6 +540,7 @@ unify ctxt env (topx, xfrom) (topy, yfrom) inj holes usersupp from =
534540 | (injectiveApp fx && injectiveApp fy)
535541 || (injectiveApp fx && metavarApp fy && ax == ay)
536542 || (injectiveApp fy && metavarApp fx && ax == ay)
543+ || (injectiveTC fx fy) -- data interface method
537544 = do let (headx, _) = unApply fx
538545 let (heady, _) = unApply fy
539546 -- fail quickly if the heads are disjoint
@@ -612,6 +619,15 @@ unify ctxt env (topx, xfrom) (topy, yfrom) inj holes usersupp from =
612619
613620 notFn t = injective t || metavar t || inenv t
614621
622+ injectiveTC t@(P Ref n _) t'@(P Ref n' _)
623+ | Just ni <- lookupInjectiveExact n ctxt,
624+ Just ni' <- lookupInjectiveExact n' ctxt
625+ = (n == n' && ni) ||
626+ (ni && metavar t') ||
627+ (metavar t && ni')
628+ injectiveTC (App _ f a) (App _ f' a') = injectiveTC f f'
629+ injectiveTC _ _ = False
630+
615631
616632 unifyTmpFail :: Term -> Term -> StateT UInfo TC [(Name, TT Name)]
617633 unifyTmpFail x y