@@ -2,7 +2,8 @@
3module Idris.CaseSplit(split, splitOnLine, replaceSplits,
3module Idris.CaseSplit(split, splitOnLine, replaceSplits,
5− mkWith) where
5+ mkWith,
6+ getUniq, nameRoot) where
7-- splitting a variable in a pattern clause
8-- splitting a variable in a pattern clause
@@ -210,18 +211,6 @@ replaceSplits l ups = updateRHSs 1 (map (rep (expandBraces l)) ups)
210 return (x : xs', i')
211 return (x : xs', i')
211 updateRHS i [] = return ("", i)
212 updateRHS i [] = return ("", 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)
220− nameRoot acc nm | all isDigit nm = showSep "_" acc
222− case span (/='_') nm of
223− (before, ('_' : after)) -> nameRoot (acc ++ [before]) after
224− _ -> showSep "_" (acc ++ [nm])
226 -- TMP HACK: If there are Nats, we don't want to show as numerals since
215 -- TMP HACK: If there are Nats, we don't want to show as numerals since
227 -- this isn't supported in a pattern, so special case here
216 -- 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)
255 addBrackets tm | ' ' `elem` tm = "(" ++ tm ++ ")"
244 addBrackets tm | ' ' `elem` tm = "(" ++ tm ++ ")"
256 | otherwise = tm
245 | otherwise = tm
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)
254+nameRoot acc nm | all isDigit nm = showSep "_" acc
256+ case span (/='_') nm of
257+ (before, ('_' : after)) -> nameRoot (acc ++ [before]) after
258+ _ -> showSep "_" (acc ++ [nm])
258getClause :: Int -> -- ^ Line type is declared on
259getClause :: Int -> -- ^ Line type is declared on
259 Name -> -- ^ Function name
260 Name -> -- ^ Function name
260 FilePath -> -- ^ Source file name
261 FilePath -> -- ^ Source file name