From ce2cef43509f7912089443c0a651cb334fd9bcc5 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 22 Dec 2009 10:14:12 +0100 Subject: Slightly cleaner split function. --- src/Text/Hakyll/Util.hs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/Text') 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) -- cgit v1.2.3