packages feed

row-types-aeson 1.0.0.0 → 1.1.0.0

raw patch · 3 files changed

+13/−13 lines, 3 filesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson

API changes (from Hackage documentation)

Files

README.md view
@@ -1,7 +1,7 @@ Row-Types-aeson ======= -[![Build Status](https://github.com/target/row-types/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/target/row-types/)+[![Build Status](https://github.com/dwincort/row-types/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/dwincort/row-types/) [![Hackage](https://img.shields.io/hackage/v/row-types-aeson.svg)](https://hackage.haskell.org/package/row-types)  Row-types-aeson is a small extension to the [row-types library](https://hackage.haskell.org/package/row-types)
row-types-aeson.cabal view
@@ -1,10 +1,10 @@ Name:                row-types-aeson-Version:             1.0.0.0+Version:             1.1.0.0 License:             MIT License-file:        LICENSE-Author:              Daniel Winograd-Cort, Matthew Farkas-Dyck+Author:              Daniel Winograd-Cort Maintainer:          dwincort@gmail.com-homepage:            https://github.com/target/row-types+homepage:            https://github.com/dwincort/row-types Build-Type:          Simple Cabal-Version:       >=1.10 Tested-With:         GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.7, GHC == 9.0.1@@ -22,7 +22,7 @@ library   default-language: Haskell2010   Build-Depends:-    aeson,+    aeson >= 2,     base >= 2 && < 6,     row-types,     text@@ -34,4 +34,4 @@  source-repository head     type:     git-    location: https://github.com/target/row-types/+    location: https://github.com/dwincort/row-types/
src/Data/Row/Aeson.hs view
@@ -16,24 +16,24 @@  import           Data.Aeson import           Data.Aeson.Encoding (pairStr)+import qualified Data.Aeson.KeyMap as KeyMap import           Data.Aeson.Types    (typeMismatch) import           Data.List           (intercalate)-import           Data.Text           (Text)-import qualified Data.Text           as Text (pack)+import           Data.String         (IsString (fromString))  import           Data.Row import qualified Data.Row.Records  as Rec import qualified Data.Row.Variants as Var  instance Forall r ToJSON => ToJSON (Rec r) where-  toJSON = Object . Rec.eraseToHashMap @ToJSON toJSON+  toJSON = Object . KeyMap.fromList . Rec.eraseWithLabels @ToJSON toJSON    toEncoding =     pairs . foldMap (uncurry pairStr) . Rec.eraseWithLabels @ToJSON toEncoding  instance (AllUniqueLabels r, Forall r FromJSON) => FromJSON (Rec r) where   parseJSON (Object o) = do-    r <- Rec.fromLabelsA @FromJSON $ \ l -> do x <- o .: (show' l)+    r <- Rec.fromLabelsA @FromJSON $ \ l -> do x <- o .: show' l                                                x `seq` pure x     r `seq` pure r @@ -45,9 +45,9 @@     where (l, foo) = Var.eraseWithLabels @ToJSON (\v l -> l .= v) v  instance (AllUniqueLabels r, Forall r FromJSON) => FromJSON (Var r) where-  parseJSON (Object o) = Var.fromLabels @FromJSON $ \ l -> o .: (show' l)+  parseJSON (Object o) = Var.fromLabels @FromJSON $ \ l -> o .: show' l   parseJSON v = typeMismatch msg v     where msg = "VAR: {" ++ intercalate "," (labels @r @FromJSON) ++ "}" -show' :: Show a => a -> Text-show' = Text.pack . show+show' :: (IsString s, Show a) => a -> s+show' = fromString . show