Skip to content

Commit

Permalink
build with aeson 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robx committed May 17, 2022
1 parent 72f45fe commit f443e6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions puzzle-draw.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/Parse/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ 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)

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 =
Expand Down

0 comments on commit f443e6f

Please sign in to comment.