Skip to content

Commit d5f52fe

Browse files
committed
Allow aeson 2.0
1 parent ca65bb9 commit d5f52fe

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

haxl.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extra-source-files:
4343
library
4444

4545
build-depends:
46-
aeson >= 0.6 && < 1.6,
46+
aeson >= 0.6 && < 2.1,
4747
base >= 4.10 && < 5,
4848
binary >= 0.7 && < 0.10,
4949
bytestring >= 0.9 && < 0.11,

stack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-8.15
1+
resolver: lts-19.2
22

33
packages:
44
- '.'

stack.yaml.lock

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/lock_files
5+
6+
packages: []
7+
snapshots:
8+
- completed:
9+
size: 617368
10+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/2.yaml
11+
sha256: e7e57649a12f6178d1158e4b6f1f1885ed56d210ae6174385271cecc9b1ea974
12+
original: lts-19.2

tests/ProfileTests.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Control.Exception (evaluate)
2323
import Data.Aeson
2424
import Data.IORef
2525
import qualified Data.HashMap.Strict as HashMap
26+
import qualified Data.Aeson.KeyMap as KeyMap
2627
import Data.Int
2728

2829
import TestUtils
@@ -53,7 +54,7 @@ collectsdata = do
5354
slp <- sum <$> mapM (\x -> withLabel "baz" $ return x) [1..5]
5455
-- do some non-trivial work that can't be lifted out
5556
-- first sleep though in order to force a Blocked result
56-
sleep slp `andThen` case fromJSON <$> HashMap.lookup "A" u of
57+
sleep slp `andThen` case fromJSON <$> KeyMap.lookup "A" u of
5758
Just (Success n) | sum [n .. 1000::Integer] > 0 -> return 5
5859
_otherwise -> return (4::Int)
5960
profCopy <- readIORef (profRef e)
@@ -94,7 +95,7 @@ collectsLazyData = do
9495
_x <- runHaxl e $ withLabel "bar" $ do
9596
u <- env userEnv
9697
withLabel "foo" $ do
97-
let start = if HashMap.member "A" u
98+
let start = if KeyMap.member "A" u
9899
then 10
99100
else 1
100101
return $ sum [start..10000::Integer]

tests/TestTypes.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ module TestTypes
1818

1919
import Data.Aeson
2020
import Data.Binary (Binary)
21-
import Data.Text (Text)
2221
import qualified Data.Text as Text
23-
import qualified Data.HashMap.Strict as HashMap
22+
import qualified Data.Aeson.KeyMap as KeyMap
23+
import Data.Aeson.Key (toText)
2424
import Data.Hashable
2525
import Data.Typeable
2626

@@ -30,17 +30,17 @@ type UserEnv = Object
3030
type Haxl a = GenHaxl UserEnv () a
3131
type HaxlEnv = Env UserEnv ()
3232

33-
lookupInput :: FromJSON a => Text -> Haxl a
33+
lookupInput :: FromJSON a => Key -> Haxl a
3434
lookupInput field = do
35-
mb_val <- env (HashMap.lookup field . userEnv)
35+
mb_val <- env (KeyMap.lookup field . userEnv)
3636
case mb_val of
3737
Nothing ->
38-
throw (NotFound (Text.concat ["field ", field, " was not found."]))
38+
throw (NotFound (Text.concat ["field ", toText field, " was not found."]))
3939
Just val ->
4040
case fromJSON val of
4141
Error str ->
4242
throw (UnexpectedType (Text.concat
43-
["field ", field, ": ", Text.pack str]))
43+
["field ", toText field, ": ", Text.pack str]))
4444
Success a -> return a
4545

4646

tests/TestUtils.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import Haxl.DataSource.ConcurrentIO
2121
import Data.IORef
2222
import Data.Aeson
2323
import Test.HUnit
24-
import qualified Data.HashMap.Strict as HashMap
24+
import qualified Data.Aeson.KeyMap as KM
2525

2626
import Haxl.Core
2727

2828
import Prelude()
2929
import Haxl.Prelude
3030

3131
testinput :: Object
32-
testinput = HashMap.fromList [
32+
testinput = KM.fromList [
3333
"A" .= (1 :: Int),
3434
"B" .= (2 :: Int),
3535
"C" .= (3 :: Int),

0 commit comments

Comments
 (0)