@@ -1282,6 +1282,25 @@ stripLinear i tm = evalState (sl tm) [] where
12821282 return $ PTacImplicit p l n sc t' d
12831283 sl x = return x
12841284
1285+-- Remove functions which aren't applied to anything, which must then
1286+-- be resolved by unification. Assume names resolved and alternatives
1287+-- filled in (so no ambiguity).
1288+
1289+stripUnmatchable :: IState -> PTerm -> PTerm
1290+stripUnmatchable i (PApp fc fn args) = PApp fc fn (fmap (fmap su) args) where
1291+ su :: PTerm -> PTerm
1292+ su (PRef fc f)
1293+ | (Bind n (Pi t) sc :_) <- lookupTy f (tt_ctxt i)
1294+ = Placeholder
1295+ su (PApp fc fn args)
1296+ = PApp fc fn (fmap (fmap su) args)
1297+ su (PAlternative b alts)
1298+ = PAlternative b (filter (/= Placeholder) (map su alts))
1299+ su (PPair fc l r) = PPair fc (su l) (su r)
1300+ su (PDPair fc l t r) = PDPair fc (su l) (su t) (su r)
1301+ su t = t
1302+stripUnmatchable i tm = tm
1303+
12851304mkPApp fc a f [] = f
12861305mkPApp fc a f as = let rest = drop a as in
12871306 appRest fc (PApp fc f (take a as)) rest