aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-02-23 16:28:40 +0100
committerFélix Sipma <felix.sipma@no-log.org>2018-02-23 16:28:40 +0100
commit94908a68e380b23e1154402fce7a49c3262b9314 (patch)
tree057551bf910d4004a2f6de267c656431b6084dcf
parentc0ab31a9c19da6dc9f9f29df5304f07c0415c1d7 (diff)
upgrade aeson version
-rw-r--r--perfeed.cabal2
-rw-r--r--src/Filter.hs11
2 files changed, 7 insertions, 6 deletions
diff --git a/perfeed.cabal b/perfeed.cabal
index d5906dd..72f196c 100644
--- a/perfeed.cabal
+++ b/perfeed.cabal
@@ -35,7 +35,7 @@ library
, Config.InternalConfig
, Filter
build-depends: base >= 4.8 && < 5
- , aeson
+ , aeson >= 1.2
, blaze-markup
, bytestring
, conduit
diff --git a/src/Filter.hs b/src/Filter.hs
index a7f48eb..7af7eac 100644
--- a/src/Filter.hs
+++ b/src/Filter.hs
@@ -12,7 +12,9 @@ module Filter
) where
import Protolude
+import Control.Monad ( fail )
import Data.Aeson
+import Data.Aeson.Types
import Data.String ( words, unwords )
import Text.XML.Cursor ( Cursor )
import qualified Control.Exception as E
@@ -28,10 +30,9 @@ import Control.Monad.Logger ( MonadLogger, logError )
import Types
-getCursorFilter :: Text -> FeedFilter
-getCursorFilter "id" = CursorFilter "id" identity
-getCursorFilter s = error $ "UnKnown filter: i" <> s
--- ^ TODO: remove error
+getCursorFilter :: Text -> Parser FeedFilter
+getCursorFilter "id" = return (CursorFilter "id" identity)
+getCursorFilter s = fail $ "Invalid filter \"" <> toS s <> "\""
data FeedFilter
= CursorFilter Text (Cursor -> Cursor)
@@ -39,7 +40,7 @@ data FeedFilter
instance FromJSON FeedFilter where
parseJSON (Object o) =
- getCursorFilter <$> o .: "internal"
+ (getCursorFilter =<< (o .: "internal"))
<|> parseExternalFilter <$> o .: "external"
parseJSON _ = mzero