on master help sign in
Slightly cleaner split function.
commitce2cef43509f7912089443c0a651cb334fd9bcc5 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 22 Dec 2009, 10:14 (17 years ago) parent137bf68
1 file changed+3−7
src/Text/Hakyll/Util.hs+3−7
src/Text/Hakyll/Util.hs+3−7
@@ -6,6 +6,7 @@ module Text.Hakyll.Util
66
77import Data.Char
88import Data.List
9+import Text.Regex
910
1011-- | Trim a string (drop spaces and tabs at both sides).
1112trim :: String -> String
@@ -23,10 +24,5 @@ stripHTML str = let (beforeTag, rest) = break (== '<') str
2324 tail' xs = tail xs
2425
2526-- | Split a list at a certain element.
26−split :: (Eq a) => a -> [a] -> [[a]]
27−split element = unfoldr splitOnce
28− where splitOnce l = let r = break (== element) l
29− in case r of ([], []) -> Nothing
30− (x, xs) -> if null xs
31− then Just (x, [])
32− else Just (x, tail xs)
27+split :: String -> String -> [String]
28+split pattern = splitRegex (mkRegex pattern)