aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-12-14 17:58:55 +0100
committerFélix Sipma <felix.sipma@no-log.org>2018-12-14 17:58:55 +0100
commitd40af59f545499badd1750f43681d54f228d8de4 (patch)
treeeb500a57077fc51472e3008d5625fde226293939
parent1c29da010b7574dcbb682179b5d2da40ea54e462 (diff)
support yaml < 0.8.31
-rw-r--r--perfeed.cabal2
-rw-r--r--src/Config/FileConfig.hs8
2 files changed, 9 insertions, 1 deletions
diff --git a/perfeed.cabal b/perfeed.cabal
index fb97c85..84d92fe 100644
--- a/perfeed.cabal
+++ b/perfeed.cabal
@@ -63,7 +63,7 @@ library
, unix
, unliftio-core
, xml-conduit >= 1.3.0
- , yaml >= 0.8.31
+ , yaml >= 0.8
default-language: Haskell2010
default-extensions: NoImplicitPrelude
if flag(dev)
diff --git a/src/Config/FileConfig.hs b/src/Config/FileConfig.hs
index c268950..bb34e04 100644
--- a/src/Config/FileConfig.hs
+++ b/src/Config/FileConfig.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Config.FileConfig
( parseConfigFile
@@ -50,7 +51,14 @@ parseConfigFile p = fileConfigToInternalConfig <$> parseConfigFile' p
parseConfigFile' :: Path Abs File -> IO FileConfig
parseConfigFile' config = do
content <- BS.readFile fpConfig
+#if MIN_VERSION_yaml(0,8,31)
Y.decodeThrow content
+#else
+ case (Y.decode content :: Maybe FileConfig) of
+ Nothing -> throwIO $ "ParseConfigError: Could not parse config file \"" <> fpConfig <> "\""
+ Just c -> return c
+
+#endif
where
fpConfig = toFilePath config