@@ -914,6 +914,39 @@ aiFn inpat expat ist fc f as
914914 | n == n' = Just (t, reverse acc ++ gs)
915915 find n (g : gs) acc = find n gs (g : acc)
916916
917+-- replace non-linear occurrences with _
918+stripLinear :: IState -> PTerm -> PTerm
919+stripLinear i tm = evalState (sl tm) [] where
920+ sl :: PTerm -> State [Name] PTerm
921+ sl (PRef fc f)
922+ | (_:_) <- lookupTy Nothing f (tt_ctxt i)
923+ = return $ PRef fc f
924+ | otherwise = do ns <- get
925+ trace (show (f, ns)) $ if (f `elem` ns)
926+ then return Placeholder
927+ else do put (f : ns)
928+ return (PRef fc f)
929+ sl (PPatvar fc f)
930+ = do ns <- get
931+ if (f `elem` ns)
932+ then return Placeholder
933+ else do put (f : ns)
934+ return (PRef fc f)
935+ sl (PApp fc fn args) = do fn' <- sl fn
936+ args' <- mapM slA args
937+ return $ PApp fc fn' args'
938+ where slA (PImp p l n t d) = do t' <- sl t
939+ return $ PImp p l n t' d
940+ slA (PExp p l t d) = do t' <- sl t
941+ return $ PExp p l t' d
942+ slA (PConstraint p l t d)
943+ = do t' <- sl t
944+ return $ PConstraint p l t' d
945+ slA (PTacImplicit p l n sc t d)
946+ = do t' <- sl t
947+ return $ PTacImplicit p l n sc t' d
948+ sl x = return x
949+
917950mkPApp fc a f [] = f
918951mkPApp fc a f as = let rest = drop a as in
919952 appRest fc (PApp fc f (take a as)) rest