packages feed

aeson-value-parser 0.18 → 0.18.1

raw patch · 3 files changed

+21/−1 lines, 3 filesdep +text-builderPVP ok

version bump matches the API change (PVP)

Dependencies added: text-builder

API changes (from Hackage documentation)

+ Aeson.ValueParser: runWithTextError :: Value a -> Value -> Either Text a

Files

aeson-value-parser.cabal view
@@ -1,5 +1,5 @@ name: aeson-value-parser-version: 0.18+version: 0.18.1 synopsis: API for parsing "aeson" JSON tree into Haskell types description:   A flexible parser DSL of JSON AST produced by the \"aeson\" library@@ -41,6 +41,7 @@     mtl >=2.2 && <3,     scientific ==0.3.*,     text ==1.*,+    text-builder >=0.6.6.1 && <0.7,     transformers >=0.5 && <0.7,     unordered-containers ==0.2.*,     vector >=0.10 && <0.13
library/Aeson/ValueParser.hs view
@@ -7,6 +7,7 @@ (   Value,   run,+  runWithTextError,   Error.Error(..),   -- * Value parsers   object,@@ -92,6 +93,10 @@     Aeson.Number _ -> "Unexpected type: number"     Aeson.Bool _ -> "Unexpected type: bool"     Aeson.Null -> "Unexpected type: null"++{-# INLINE runWithTextError #-}+runWithTextError :: Value a -> Aeson.Value -> Either Text a+runWithTextError parser = left Error.toText . run parser  runString :: String a -> Text -> Either (Maybe Text) a runString (String a) b = runExcept (runReaderT a b)
library/Aeson/ValueParser/Error.hs view
@@ -2,6 +2,8 @@ where  import Aeson.ValueParser.Prelude+import qualified Data.Text as Text+import qualified Text.Builder as TextBuilder   data Error = Error [Text] {-^ Path -} Text {-^ Message -}@@ -16,6 +18,9 @@ instance IsString Error where   fromString = message . fromString +instance Show Error where+  show = Text.unpack . toText+ {-# INLINE indexed #-} indexed :: Int -> Error -> Error indexed = named . fromString . show@@ -27,3 +32,12 @@ {-# INLINE message #-} message :: Text -> Error message = Error []++toText :: Error -> Text+toText = TextBuilder.run . toTextBuilder++toTextBuilder :: Error -> TextBuilder.Builder+toTextBuilder (Error path message) =+  "AST parsing error at path " <>+  foldMap (\ x -> "/" <> TextBuilder.text x) path <> ": " <>+  TextBuilder.text message