summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Util.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-04 15:51:07 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-04 15:51:07 +0100
commitcf5aaee05169c96f79b719a721af411edbb18449 (patch)
tree7082193151ea8c3af5b22af3279651d135a34006 /src/Text/Hakyll/Util.hs
parentd3ce014d2643fc62aa5af5b54b298fb083bf25b0 (diff)
downloadhakyll-cf5aaee05169c96f79b719a721af411edbb18449.tar.gz
Added string splitting.
Diffstat (limited to 'src/Text/Hakyll/Util.hs')
-rw-r--r--src/Text/Hakyll/Util.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
index 50a36e6..83348c3 100644
--- a/src/Text/Hakyll/Util.hs
+++ b/src/Text/Hakyll/Util.hs
@@ -8,6 +8,7 @@ import System.Directory
import System.FilePath
import Control.Monad
import Data.Char
+import Data.List
-- | Given a path to a file, try to make the path writable by making
-- all directories on the path.
@@ -34,3 +35,12 @@ getRecursiveContents topdir = do
trim :: String -> String
trim = reverse . trim' . reverse . trim'
where trim' = dropWhile isSpace
+
+-- | 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)