summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Util.hs
diff options
context:
space:
mode:
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)