on master help sign in
Update to work with 20.9 snapshot
96febf9iko
jrec.cabal+1−1
@@ -37,7 +37,7 @@ common library-common
37 default-language: Haskell2010
37 default-language: Haskell2010
38 build-depends:
38 build-depends:
39 aeson
39 aeson
40− , base >=4.13 && <4.15
40+ , base >=4.13 && <4.17
41 , constraints
41 , constraints
42 , deepseq
42 , deepseq
43 , generic-data
43 , generic-data
src/JRec/Internal.hs+6−5
@@ -46,6 +46,7 @@ import GHC.TypeLits
46import qualified Optics.Lens as OL
46import qualified Optics.Lens as OL
47import Unsafe.Coerce
47import Unsafe.Coerce
48import Prelude
48import Prelude
49+import qualified Data.Aeson.Key as Key
49
50
50-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
51-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
51-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
52-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -558,16 +559,16 @@ class ToJSON a => EncodeField a where
558
559
559instance ToJSON a => EncodeField a where
560instance ToJSON a => EncodeField a where
560 encodeField = pure . toJSON
561 encodeField = pure . toJSON
561− encodeKV = (.=)
562+ encodeKV k v = Key.fromText k .= v
562
563
563instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
564 encodeField = fmap toJSON
565 encodeField = fmap toJSON
565 encodeKV _ Nothing = mempty
566 encodeKV _ Nothing = mempty
566− encodeKV k v = k .= v
567+ encodeKV k v = Key.fromText k .= v
567
568
568recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
569recToValue options r =
570recToValue options r =
570− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (T.pack (fieldTransform options k),) <$> encodeField v) r
571+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (Key.fromString (fieldTransform options k),) <$> encodeField v) r
571
572
572recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
573recToEncoding options r =
574recToEncoding options r =
@@ -672,10 +673,10 @@ class FromJSON a => ParseField a where
672 parseField :: Object -> T.Text -> Parser a
673 parseField :: Object -> T.Text -> Parser a
673
674
674instance FromJSON a => ParseField a where
675instance FromJSON a => ParseField a where
675− parseField = (.:)
676+ parseField o k = o .: Key.fromText k
676
677
677instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
678− parseField = (.:?)
679+ parseField o k = o .:? Key.fromText k
679
680
680instance
681instance
681 ( KnownSymbol l,
682 ( KnownSymbol l,