on 7f26cbb help sign in
9 files changed+16−66
since splitsnapshots
unifiedsplit
.github/workflows/ci.yaml−2 .vscode/extensions.json−11 .vscode/settings.json+4−5 CHANGELOG.md−4 bin/test+1−1 flake.lock+1−18 flake.nix+4−11 shell.nix−1 src/JRec/Internal.hs+6−13
.github/workflows/ci.yaml−2
@@ -13,5 +13,3 @@ jobs:
1313 experimental-features = nix-command flakes
1414 - name: Build and test 🔧
1515 run: nix build -j 4 -L
16− - name: Build and test (GHC 8.8) 🔧
17− run: nix build -j 4 -L .#jrec-ghc88
.vscode/extensions.jsondeleted−11
@@ -1,11 +0,0 @@
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+4−5
@@ -1,6 +1,5 @@
11{
2− "editor.formatOnType": true,
3− "editor.formatOnSave": true,
4− "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
5− "haskell.manageHLS": "PATH"
6−}
2+ "nixEnvSelector.nixShellConfig": "${workspaceRoot}/default.nix",
3+ "editor.formatOnType": true,
4+ "editor.formatOnSave": true
5+}
CHANGELOG.md−4
@@ -1,9 +1,5 @@
11# Revision history for rec
22
3−## Unreleased
4−
5−- GHC 9.2 + Aeson 2.0 support
6−
73## 0.1.0.0 -- YYYY-mm-dd
84
95* First version. Released on an unsuspecting world.
bin/test+1−1
@@ -2,4 +2,4 @@
22set -xe
33
44# NOTE: ghcid should be run with -W to allow warnings from should-not-typecheck
5−nix develop -c sh -c "ghcid $* -W -c 'cabal new-repl test:jrec-test' -T \":main $*\""
5+nix-shell --pure --run "ghcid $* -W -c 'cabal new-repl test:jrec-test' -T \":main $*\""
flake.lock+1−18
@@ -34,22 +34,6 @@
3434 "type": "github"
3535 }
3636 },
37− "nixpkgs-ghc88": {
38− "locked": {
39− "lastModified": 1596466290,
40− "narHash": "sha256-V1vrlYfVEdW4iauUc58LCtorSxLLF+X/PhjD5+dQjeQ=",
41− "owner": "nixos",
42− "repo": "nixpkgs",
43− "rev": "76f2e271a2ef9de3734dcc9d366a42d6bfb18e82",
44− "type": "github"
45− },
46− "original": {
47− "owner": "nixos",
48− "ref": "76f2e271a2ef",
49− "repo": "nixpkgs",
50− "type": "github"
51− }
52− },
5337 "nixpkgs-lib": {
5438 "locked": {
5539 "dir": "lib",
@@ -71,8 +55,7 @@
7155 "root": {
7256 "inputs": {
7357 "flake-parts": "flake-parts",
74− "nixpkgs": "nixpkgs",
75− "nixpkgs-ghc88": "nixpkgs-ghc88"
58+ "nixpkgs": "nixpkgs"
7659 }
7760 }
7861 },
flake.nix+4−11
@@ -1,7 +1,6 @@
11{
22 inputs = {
33 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4− nixpkgs-ghc88.url = "github:nixos/nixpkgs/76f2e271a2ef";
54 flake-parts.url = "github:hercules-ci/flake-parts";
65 };
76 outputs = inputs@{ nixpkgs, flake-parts, ... }:
@@ -12,23 +11,17 @@
1211 overlay = self: super: {
1312 jrec = self.callCabal2nix "jrec" ./. { };
1413 };
15− ghcVersions = {
16− ghc88 = inputs.nixpkgs-ghc88.legacyPackages.${system}.haskellPackages.extend overlay;
17− ghc92 = pkgs.haskellPackages.extend overlay;
18− };
14+ haskellPackages' = pkgs.haskellPackages.extend overlay;
1915 in
2016 {
21− packages.default = ghcVersions.ghc92.jrec;
22− devShells.default = ghcVersions.ghc92.shellFor {
17+ packages.default = haskellPackages'.jrec;
18+ devShells.default = haskellPackages'.shellFor {
2319 packages = p: [ p.jrec ];
24− buildInputs = with ghcVersions.ghc92; [
20+ buildInputs = with haskellPackages'; [
2521 cabal-install
26− ghcid
2722 haskell-language-server
2823 ];
2924 };
30− # Expose jrec built with GHC 8.8 so it can be tested in CI.
31− packages.jrec-ghc88 = ghcVersions.ghc88.jrec;
3225 };
3326 };
3427}
shell.nixdeleted−1
@@ -1 +0,0 @@
1−(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default
src/JRec/Internal.hs+6−13
@@ -46,14 +46,7 @@ import GHC.TypeLits
4646import qualified Optics.Lens as OL
4747import Unsafe.Coerce
4848import Prelude
49−#if MIN_VERSION_aeson(2,0,0)
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
49+import qualified Data.Aeson.Key as Key
5750
5851-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
5952-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -566,16 +559,16 @@ class ToJSON a => EncodeField a where
566559
567560instance ToJSON a => EncodeField a where
568561 encodeField = pure . toJSON
569− encodeKV k v = fromText k .= v
562+ encodeKV k v = Key.fromText k .= v
570563
571564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
572565 encodeField = fmap toJSON
573566 encodeKV _ Nothing = mempty
574− encodeKV k v = fromText k .= v
567+ encodeKV k v = Key.fromText k .= v
575568
576569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
577570recToValue options r =
578− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (fromString (fieldTransform options k),) <$> encodeField v) r
571+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (Key.fromString (fieldTransform options k),) <$> encodeField v) r
579572
580573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
581574recToEncoding options r =
@@ -680,10 +673,10 @@ class FromJSON a => ParseField a where
680673 parseField :: Object -> T.Text -> Parser a
681674
682675instance FromJSON a => ParseField a where
683− parseField o k = o .: fromText k
676+ parseField o k = o .: Key.fromText k
684677
685678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
686− parseField o k = o .:? fromText k
679+ parseField o k = o .:? Key.fromText k
687680
688681instance
689682 ( KnownSymbol l,