From 885e22ce180be7d9c94aa7ac19e7e5a8a7d8ec6c Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Tue, 17 May 2022 17:02:15 +0200 Subject: [PATCH] build with aeson 2.0 --- puzzle-draw.cabal | 8 ++++---- src/Parse/Util.hs | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/puzzle-draw.cabal b/puzzle-draw.cabal index 7b96a7f..41e0c10 100644 --- a/puzzle-draw.cabal +++ b/puzzle-draw.cabal @@ -67,7 +67,7 @@ library diagrams-lib >=1.4.2.3 && <1.5, parsec >=3.1, yaml >=0.8.4, - aeson >=0.7, + aeson >=2.0, unordered-containers >=0.2, containers >=0.5, hashable >=1.2, @@ -97,7 +97,7 @@ executable drawpuzzle diagrams-lib >=1.4.2.3 && <1.5, yaml >=0.8.4, optparse-applicative >=0.12, - aeson >=0.7, + aeson >=2.0, filepath >=1.3, bytestring >=0.10, diagrams-rasterific >=1.4.2, @@ -113,7 +113,7 @@ executable checkpuzzle yaml >=0.8.4, containers >=0.5, optparse-applicative >=0.12, - aeson >=0.7, + aeson >=2.0, bytestring >=0.10, filepath >=1.3 @@ -128,7 +128,7 @@ executable servepuzzle snap-core >=0.9, snap-server >=0.9, diagrams-lib >=1.2, - aeson >=0.7, + aeson >=2.0, yaml >=0.8.4, filepath >=1.3, directory >=1.2, diff --git a/src/Parse/Util.hs b/src/Parse/Util.hs index e2f0708..5731906 100644 --- a/src/Parse/Util.hs +++ b/src/Parse/Util.hs @@ -32,6 +32,7 @@ import Data.Ord (comparing) import qualified Data.Text as T import Data.Traversable (mapM) import Data.Yaml +import qualified Data.Aeson.Key import Parse.Parsec import Text.Read (readMaybe) import Prelude hiding (mapM) @@ -39,11 +40,11 @@ import Prelude hiding (mapM) type Path = [String] field :: Path -> Value -> Parser Value -field = field' . map T.pack +field = field' . map (Data.Aeson.Key.fromText . T.pack) where field' [] v = pure v field' (f : fs) (Object v) = v .: f >>= field' fs - field' (f : _) _ = fail $ "expected field '" ++ T.unpack f ++ "'" + field' (f : _) _ = fail $ "expected field '" ++ (T.unpack . Data.Aeson.Key.toText $ f) ++ "'" parseFrom :: Path -> (Value -> Parser b) -> Value -> Parser b parseFrom fs p v =