summaryrefslogtreecommitdiff
path: root/src/Data/List
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2016-04-06 14:26:46 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2016-04-06 14:26:46 +0200
commite81468e0f64fdbe05794d5f8ccaebc00ee474ee2 (patch)
tree882c422a312ed3e6eb8eaacfcc9c292a09296845 /src/Data/List
parent3f3e09672d3d279bc5cbaa8b3ac7508abc98aa2d (diff)
downloadhakyll-e81468e0f64fdbe05794d5f8ccaebc00ee474ee2.tar.gz
Initial YAML support
See #225
Diffstat (limited to 'src/Data/List')
-rw-r--r--src/Data/List/Extended.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Data/List/Extended.hs b/src/Data/List/Extended.hs
new file mode 100644
index 0000000..485cba8
--- /dev/null
+++ b/src/Data/List/Extended.hs
@@ -0,0 +1,15 @@
+module Data.List.Extended
+ ( module Data.List
+ , breakWhen
+ ) where
+
+import Data.List
+
+-- | Like 'break', but can act on the entire tail of the list.
+breakWhen :: ([a] -> Bool) -> [a] -> ([a], [a])
+breakWhen predicate = go []
+ where
+ go buf [] = (reverse buf, [])
+ go buf (x : xs)
+ | predicate (x : xs) = (reverse buf, x : xs)
+ | otherwise = go (x : buf) xs