diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2016-04-06 14:26:46 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2016-04-06 14:26:46 +0200 |
commit | e81468e0f64fdbe05794d5f8ccaebc00ee474ee2 (patch) | |
tree | 882c422a312ed3e6eb8eaacfcc9c292a09296845 /src/Data | |
parent | 3f3e09672d3d279bc5cbaa8b3ac7508abc98aa2d (diff) | |
download | hakyll-e81468e0f64fdbe05794d5f8ccaebc00ee474ee2.tar.gz |
Initial YAML support
See #225
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/List/Extended.hs | 15 | ||||
-rw-r--r-- | src/Data/Yaml/Extended.hs | 17 |
2 files changed, 32 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 diff --git a/src/Data/Yaml/Extended.hs b/src/Data/Yaml/Extended.hs new file mode 100644 index 0000000..9ad05f3 --- /dev/null +++ b/src/Data/Yaml/Extended.hs @@ -0,0 +1,17 @@ +module Data.Yaml.Extended + ( module Data.Yaml + , toString + , toList + ) where + +import qualified Data.Text as T +import qualified Data.Vector as V +import Data.Yaml + +toString :: Value -> Maybe String +toString (String t) = Just (T.unpack t) +toString _ = Nothing + +toList :: Value -> Maybe [Value] +toList (Array a) = Just (V.toList a) +toList _ = Nothing |