diff --git a/haxl.cabal b/haxl.cabal index 8106318..f96e728 100644 --- a/haxl.cabal +++ b/haxl.cabal @@ -43,7 +43,7 @@ extra-source-files: library build-depends: - aeson >= 0.6 && < 1.6, + aeson >= 0.6 && < 2.1, base >= 4.10 && < 5, binary >= 0.7 && < 0.10, bytestring >= 0.9 && < 0.11, diff --git a/stack.yaml b/stack.yaml index 10b0c58..df137d5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-8.15 +resolver: lts-19.2 packages: - '.' diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..5e0d4ce --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + size: 617368 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/2.yaml + sha256: e7e57649a12f6178d1158e4b6f1f1885ed56d210ae6174385271cecc9b1ea974 + original: lts-19.2 diff --git a/tests/ProfileTests.hs b/tests/ProfileTests.hs index 8d31175..ae44fa3 100644 --- a/tests/ProfileTests.hs +++ b/tests/ProfileTests.hs @@ -7,6 +7,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE CPP #-} module ProfileTests where @@ -23,6 +24,11 @@ import Control.Exception (evaluate) import Data.Aeson import Data.IORef import qualified Data.HashMap.Strict as HashMap +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.KeyMap as KeyMap +#else +import qualified Data.HashMap.Strict as KeyMap +#endif import Data.Int import TestUtils @@ -53,7 +59,7 @@ collectsdata = do slp <- sum <$> mapM (\x -> withLabel "baz" $ return x) [1..5] -- do some non-trivial work that can't be lifted out -- first sleep though in order to force a Blocked result - sleep slp `andThen` case fromJSON <$> HashMap.lookup "A" u of + sleep slp `andThen` case fromJSON <$> KeyMap.lookup "A" u of Just (Success n) | sum [n .. 1000::Integer] > 0 -> return 5 _otherwise -> return (4::Int) profCopy <- readIORef (profRef e) @@ -94,7 +100,7 @@ collectsLazyData = do _x <- runHaxl e $ withLabel "bar" $ do u <- env userEnv withLabel "foo" $ do - let start = if HashMap.member "A" u + let start = if KeyMap.member "A" u then 10 else 1 return $ sum [start..10000::Integer] diff --git a/tests/TestTypes.hs b/tests/TestTypes.hs index 1f533d5..cb5e1a2 100644 --- a/tests/TestTypes.hs +++ b/tests/TestTypes.hs @@ -7,6 +7,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE CPP #-} module TestTypes ( UserEnv @@ -18,29 +19,40 @@ module TestTypes import Data.Aeson import Data.Binary (Binary) -import Data.Text (Text) import qualified Data.Text as Text -import qualified Data.HashMap.Strict as HashMap +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.KeyMap as KeyMap +import Data.Aeson.Key (toText) +#else +import qualified Data.HashMap.Strict as KeyMap +#endif import Data.Hashable import Data.Typeable import Haxl.Core +#if !MIN_VERSION_aeson(2,0,0) +type Key = Text.Text + +toText :: Key -> Text.Text +toText = id +#endif + type UserEnv = Object type Haxl a = GenHaxl UserEnv () a type HaxlEnv = Env UserEnv () -lookupInput :: FromJSON a => Text -> Haxl a +lookupInput :: FromJSON a => Key -> Haxl a lookupInput field = do - mb_val <- env (HashMap.lookup field . userEnv) + mb_val <- env (KeyMap.lookup field . userEnv) case mb_val of Nothing -> - throw (NotFound (Text.concat ["field ", field, " was not found."])) + throw (NotFound (Text.concat ["field ", toText field, " was not found."])) Just val -> case fromJSON val of Error str -> throw (UnexpectedType (Text.concat - ["field ", field, ": ", Text.pack str])) + ["field ", toText field, ": ", Text.pack str])) Success a -> return a diff --git a/tests/TestUtils.hs b/tests/TestUtils.hs index e8ba513..92201a4 100644 --- a/tests/TestUtils.hs +++ b/tests/TestUtils.hs @@ -5,6 +5,7 @@ -- found in the LICENSE file. {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module TestUtils ( makeTestEnv , expectResultWithEnv @@ -21,7 +22,11 @@ import Haxl.DataSource.ConcurrentIO import Data.IORef import Data.Aeson import Test.HUnit -import qualified Data.HashMap.Strict as HashMap +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.KeyMap as KeyMap +#else +import qualified Data.HashMap.Strict as KeyMap +#endif import Haxl.Core @@ -29,7 +34,7 @@ import Prelude() import Haxl.Prelude testinput :: Object -testinput = HashMap.fromList [ +testinput = KeyMap.fromList [ "A" .= (1 :: Int), "B" .= (2 :: Int), "C" .= (3 :: Int),