@@ -3,6 +3,7 @@
33module Idris.CaseSplit(splitOnLine, replaceSplits,
44 getClause, getProofClause,
55 mkWith,
6+ nameMissing,
67 getUniq, nameRoot) where
78
89-- splitting a variable in a pattern clause
@@ -117,7 +118,7 @@ mergeAllPats ist cv t (p : ps)
117118 = let (p', MS _ _ _ u) = runState (mergePat ist t p Nothing)
118119 (MS [] [] (filter (/=cv) (patvars t)) [])
119120 ps' = mergeAllPats ist cv t ps in
120− ((p, u) : ps')
121+ ((p', u) : ps')
121122 where patvars (PRef _ n) = [n]
122123 patvars (PApp _ _ as) = concatMap (patvars . getTm) as
123124 patvars (PPatvar _ n) = [n]
@@ -357,3 +358,23 @@ mkWith str n = let str' = replaceRHS str "with (_)"
357358 | not ('=' `elem` rest) = str
358359 replaceRHS (x : rest) str = x : replaceRHS rest str
359360
361+-- Replace _ with names in missing clauses
362+
363+nameMissing :: [PTerm] -> Idris [PTerm]
364+nameMissing ps = do ist <- get
365+ newPats <- mapM nm ps
366+ let newPats' = mergeAllPats ist (UN "_") (base (head ps))
367+ newPats
368+ return (map fst newPats')
369+ where
370+ base (PApp fc f args) = PApp fc f (map (fmap (const (PRef fc (UN "_")))) args)
371+ base t = t
372+
373+ nm ptm = do mptm <- elabNewPat ptm
374+ case mptm of
375+ Nothing -> return ptm
376+ Just ptm' -> return ptm'
377+
378+
379+
380+