@@ -2,7 +2,8 @@
22
33module Idris.CaseSplit(split, splitOnLine, replaceSplits,
44 getClause,
5− mkWith) where
5+ mkWith,
6+ getUniq, nameRoot) where
67
78-- splitting a variable in a pattern clause
89
@@ -210,18 +211,6 @@ replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
210211 return (x : xs', i')
211212 updateRHS i [] = return ("", i)
212213
213− getUniq nm i
214− = do ist <- getIState
215− let n = nameRoot [] nm ++ "_" ++ show i
216− case lookupTy (UN n) (tt_ctxt ist) of
217− [] -> return (n, i+1)
218− _ -> getUniq nm (i+1)
219−
220− nameRoot acc nm | all isDigit nm = showSep "_" acc
221− nameRoot acc nm =
222− case span (/='_') nm of
223− (before, ('_' : after)) -> nameRoot (acc ++ [before]) after
224− _ -> showSep "_" (acc ++ [nm])
225214
226215 -- TMP HACK: If there are Nats, we don't want to show as numerals since
227216 -- this isn't supported in a pattern, so special case here
@@ -255,6 +244,18 @@ replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
255244 addBrackets tm | ' ' `elem` tm = "(" ++ tm ++ ")"
256245 | otherwise = tm
257246
247+getUniq nm i
248+ = do ist <- getIState
249+ let n = nameRoot [] nm ++ "_" ++ show i
250+ case lookupTy (UN n) (tt_ctxt ist) of
251+ [] -> return (n, i+1)
252+ _ -> getUniq nm (i+1)
253+
254+nameRoot acc nm | all isDigit nm = showSep "_" acc
255+nameRoot acc nm =
256+ case span (/='_') nm of
257+ (before, ('_' : after)) -> nameRoot (acc ++ [before]) after
258+ _ -> showSep "_" (acc ++ [nm])
258259getClause :: Int -> -- ^ Line type is declared on
259260 Name -> -- ^ Function name
260261 FilePath -> -- ^ Source file name