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 =