Commit f06f40fb authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

Move snocView in the file, nearer the other spliting functions

parent f078c036
......@@ -326,15 +326,6 @@ notNull :: [a] -> Bool
notNull [] = False
notNull _ = True
snocView :: [a] -> Maybe ([a],a)
-- Split off the last element
snocView [] = Nothing
snocView xs = go [] xs
where
-- Invariant: second arg is non-empty
go acc [x] = Just (reverse acc, x)
go acc (x:xs) = go (x:acc) xs
only :: [a] -> a
#ifdef DEBUG
only [a] = a
......@@ -629,6 +620,15 @@ splitAtList (_:xs) (y:ys) = (y:ys', ys'')
where
(ys', ys'') = splitAtList xs ys
snocView :: [a] -> Maybe ([a],a)
-- Split off the last element
snocView [] = Nothing
snocView xs = go [] xs
where
-- Invariant: second arg is non-empty
go acc [x] = Just (reverse acc, x)
go acc (x:xs) = go (x:acc) xs
split :: Char -> String -> [String]
split c s = case rest of
[] -> [chunk]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment