File tree 2 files changed +14
-4
lines changed 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ description:
17
17
category : Text, Web, JSON
18
18
build-type : Simple
19
19
extra-source-files :
20
- README.md
21
20
CHANGELOG.md
21
+ README.md
22
22
23
23
source-repository head
24
24
type : git
@@ -30,7 +30,7 @@ library
30
30
default-language : Haskell2010
31
31
ghc-options : -Wall -Wno-name-shadowing
32
32
build-depends :
33
- aeson >= 1.4 && < 2
33
+ aeson >= 1.4 && < 2.1
34
34
, base >= 4.10 && < 5
35
35
, mtl >= 2.2 && < 3
36
36
, text >= 1.2 && < 2
@@ -42,7 +42,7 @@ test-suite tasty
42
42
default-language : Haskell2010
43
43
ghc-options : -Wall -Wno-name-shadowing
44
44
build-depends :
45
- aeson >= 1.4 && < 2
45
+ aeson >= 1.4 && < 2.1
46
46
, aeson-commit
47
47
, aeson-qq >= 0.8 && < 1
48
48
, base >= 4.10 && < 5
Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2
+ {-# LANGUAGE CPP #-}
2
3
3
4
{-|
4
5
Commitment mechanism for aeson 'Parser'.
@@ -40,8 +41,12 @@ module Data.Aeson.Commit
40
41
import Control.Applicative (Alternative (.. ))
41
42
import Control.Monad.Except
42
43
import Data.Aeson.Types
43
- import Data.Text (Text )
44
44
import Data.Void (Void , absurd )
45
+ #if MIN_VERSION_aeson(2,0,0)
46
+ import qualified Data.Aeson.Key as Key
47
+ #else
48
+ import Data.Text (Text )
49
+ #endif
45
50
46
51
-- | A 'Parser' that has _two_ failure modes; recoverable and non-recoverable.
47
52
-- The default, recoverable failure is the equivalent to aeson's default 'Parser' behavior.
@@ -87,7 +92,12 @@ runCommit (Commit f) = runExceptT f >>= either handleErrors pure
87
92
88
93
-- | Convenience wrapper around 'commit' for when the commit is checking whether a key is present in some object.
89
94
-- If it is, it will commit and append the key to the JSONPath of the inner context through '<?>', which will give nicer error messages.
95
+
96
+ #if MIN_VERSION_aeson(2,0,0)
97
+ (.:>) :: FromJSON a => Object -> Key. Key -> (a -> Parser b ) -> Commit b
98
+ #else
90
99
(.:>) :: FromJSON a => Object -> Text -> (a -> Parser b ) -> Commit b
100
+ #endif
91
101
(o .:> k) cont = commit (o .: k) (\ v -> cont v <?> Key k)
92
102
93
103
-- | Turn a 'Parser' into a 'Commit'
You can’t perform that action at this time.
0 commit comments