Enable splitting emitted tokens by new lines

This commit is contained in:
2021-11-03 21:11:17 +01:00
parent 674c574fda
commit ce5267a13f
2 changed files with 23 additions and 8 deletions

View File

@@ -4,7 +4,8 @@ module Util (
bytesStr,
head,
unescape,
controlChar
controlChar,
explode
) where
import Prelude hiding (head)
@@ -57,4 +58,11 @@ controlChar x = case x of
'"' -> Just 34
'\'' -> Just 39
'0' -> Just 0
_ -> Nothing
_ -> Nothing
explode :: (Foldable f) => (a -> Bool) -> f a -> [[a]]
explode pred xs = filter (not . null) $ foldr split [[]] xs
where
split y (ys:yss)
| pred y = []:ys:yss
| otherwise = (y:ys):yss