on master help sign in
.vscode/extensions.jsonnew file+11
since splitsnapshots
unifiedsplit
@@ -0,0 +1,11 @@
1+{
2+ // See https://go.microsoft.com/fwlink/?LinkId=827846
3+ // for the documentation about the extensions.json format
4+ "recommendations": [
5+ "haskell.haskell",
6+ "arrterian.nix-env-selector",
7+ "bbenoist.nix",
8+ "jnoortheen.nix-ide",
9+ "tamasfe.even-better-toml"
10+ ]
11+}
.vscode/settings.json+5−4
@@ -1,5 +1,6 @@
1{
1{
2+ "editor.formatOnType": true,
3+ "editor.formatOnSave": true,
2− "nixEnvSelector.nixShellConfig": "${workspaceRoot}/default.nix",
4+ "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
3− "editor.formatOnType": true,
5+ "haskell.manageHLS": "PATH"
4− "editor.formatOnSave": true
5−}
6+}
CHANGELOG.md+4
@@ -1,5 +1,9 @@
1# Revision history for rec
1# Revision history for rec
2
2
3+## Unreleased
4+
5+- GHC 9.2 + Aeson 2.0 support
6+
3## 0.1.0.0 -- YYYY-mm-dd
7## 0.1.0.0 -- YYYY-mm-dd
4
8
5* First version. Released on an unsuspecting world.
9* First version. Released on an unsuspecting world.
bin/test+1−1
@@ -2,4 +2,4 @@
2set -xe
2set -xe
3
3
4# NOTE: ghcid should be run with -W to allow warnings from should-not-typecheck
4# NOTE: ghcid should be run with -W to allow warnings from should-not-typecheck
5−nix-shell --pure --run "ghcid $* -W -c 'cabal new-repl test:jrec-test' -T \":main $*\""
5+nix develop -c sh -c "ghcid $* -W -c 'cabal new-repl test:jrec-test' -T \":main $*\""
flake.nix+1
@@ -23,6 +23,7 @@
23 packages = p: [ p.jrec ];
23 packages = p: [ p.jrec ];
24 buildInputs = with ghcVersions.ghc92; [
24 buildInputs = with ghcVersions.ghc92; [
25 cabal-install
25 cabal-install
26+ ghcid
26 haskell-language-server
27 haskell-language-server
27 ];
28 ];
28 };
29 };
shell.nixnew file+1
@@ -0,0 +1 @@
1+(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default
src/JRec/Internal.hs+13−6
@@ -46,7 +46,14 @@ 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+#if MIN_VERSION_aeson(2,0,0)
49−import qualified Data.Aeson.Key as Key
50+import Data.Aeson.Key (fromText, fromString)
51+#else
52+fromText :: a -> a
53+fromText = id
54+fromString :: String -> T.Text
55+fromString = T.pack
56+#endif
50
57
51-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
58-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
52-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
59-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -559,16 +566,16 @@ class ToJSON a => EncodeField a where
559
566
560instance ToJSON a => EncodeField a where
567instance ToJSON a => EncodeField a where
561 encodeField = pure . toJSON
568 encodeField = pure . toJSON
562− encodeKV k v = Key.fromText k .= v
569+ encodeKV k v = fromText k .= v
563
570
564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
571instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
565 encodeField = fmap toJSON
572 encodeField = fmap toJSON
566 encodeKV _ Nothing = mempty
573 encodeKV _ Nothing = mempty
567− encodeKV k v = Key.fromText k .= v
574+ encodeKV k v = fromText k .= v
568
575
569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
576recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
570recToValue options r =
577recToValue options r =
571− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (Key.fromString (fieldTransform options k),) <$> encodeField v) r
578+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (fromString (fieldTransform options k),) <$> encodeField v) r
572
579
573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
580recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
574recToEncoding options r =
581recToEncoding options r =
@@ -673,10 +680,10 @@ class FromJSON a => ParseField a where
673 parseField :: Object -> T.Text -> Parser a
680 parseField :: Object -> T.Text -> Parser a
674
681
675instance FromJSON a => ParseField a where
682instance FromJSON a => ParseField a where
676− parseField o k = o .: Key.fromText k
683+ parseField o k = o .: fromText k
677
684
678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
685instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
679− parseField o k = o .:? Key.fromText k
686+ parseField o k = o .:? fromText k
680
687
681instance
688instance
682 ( KnownSymbol l,
689 ( KnownSymbol l,