diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-22 10:14:12 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-22 10:14:12 +0100 |
commit | ce2cef43509f7912089443c0a651cb334fd9bcc5 (patch) | |
tree | 3a60c24d41c8681a7b042acf053c932ec3727a71 /src/Text/Hakyll | |
parent | 137bf6880558603fbbf918e2977b88231065b8a8 (diff) | |
download | hakyll-ce2cef43509f7912089443c0a651cb334fd9bcc5.tar.gz |
Slightly cleaner split function.
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r-- | src/Text/Hakyll/Util.hs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs index aaa2952..6076dc4 100644 --- a/src/Text/Hakyll/Util.hs +++ b/src/Text/Hakyll/Util.hs @@ -6,6 +6,7 @@ module Text.Hakyll.Util import Data.Char import Data.List +import Text.Regex -- | Trim a string (drop spaces and tabs at both sides). trim :: String -> String @@ -23,10 +24,5 @@ stripHTML str = let (beforeTag, rest) = break (== '<') str tail' xs = tail xs -- | Split a list at a certain element. -split :: (Eq a) => a -> [a] -> [[a]] -split element = unfoldr splitOnce - where splitOnce l = let r = break (== element) l - in case r of ([], []) -> Nothing - (x, xs) -> if null xs - then Just (x, []) - else Just (x, tail xs) +split :: String -> String -> [String] +split pattern = splitRegex (mkRegex pattern) |