on master help sign in
.github/workflows/ci.yaml+2
since splitsnapshots
unifiedsplit
@@ -13,3 +13,5 @@ jobs:
13 experimental-features = nix-command flakes
13 experimental-features = nix-command flakes
14 - name: Build and test ๐Ÿ”ง
14 - name: Build and test ๐Ÿ”ง
15 run: nix build -j 4 -L
15 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.jsonnew file+11
@@ -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 $*\""
default.nixdeletedโˆ’36
@@ -1,36 +0,0 @@
1โˆ’let
2โˆ’ nixpkgsSrc = builtins.fetchTarball {
3โˆ’ url = "https://github.com/nixos/nixpkgs/archive/76f2e271a2ef.tar.gz";
4โˆ’ sha256 = "1r4da3kyghqq7vzya5yb295jpnha1fgp755bi6wda4fmhyaynnsp";
5โˆ’ };
6โˆ’ gitignoreSrc = builtins.fetchTarball {
7โˆ’ url = "https://github.com/hercules-ci/gitignore/archive/c4662e6.tar.gz";
8โˆ’ sha256 = "1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx";
9โˆ’ };
10โˆ’ inherit (import gitignoreSrc { inherit (pkgs); }) gitignoreSource;
11โˆ’in {
12โˆ’ compiler ? "default",
13โˆ’ pkgs ? import nixpkgsSrc {},
14โˆ’}:
15โˆ’ let
16โˆ’ haskellPackages =
17โˆ’ if compiler == "default"
18โˆ’ then pkgs.haskellPackages
19โˆ’ else pkgs.haskell.packages.${compiler};
20โˆ’ projectDrv =
21โˆ’ haskellPackages.override {
22โˆ’ overrides = self: super: with pkgs.haskell.lib; {
23โˆ’ jrec = self.callCabal2nix "jrec" (gitignoreSource ./.) {};
24โˆ’ # https://github.com/lspitzner/data-tree-print/pull/2
25โˆ’ data-tree-print = doJailbreak super.data-tree-print;
26โˆ’ };
27โˆ’ };
28โˆ’ projectShell =
29โˆ’ projectDrv.shellFor {
30โˆ’ packages = p: [ p.jrec ];
31โˆ’ buildInputs = with projectDrv; [
32โˆ’ cabal-install
33โˆ’ ];
34โˆ’ };
35โˆ’ in
36โˆ’ if pkgs.lib.inNixShell then projectShell else projectDrv.jrec
flake.lock+20โˆ’36
@@ -18,36 +18,36 @@
18 "type": "github"
18 "type": "github"
19 }
19 }
20 },
20 },
21โˆ’ "gitignore": {
21+ "nixpkgs": {
22โˆ’ "inputs": {
23โˆ’ "nixpkgs": "nixpkgs"
24โˆ’ },
25 "locked": {
22 "locked": {
26โˆ’ "lastModified": 1660459072,
23+ "lastModified": 1678594102,
27โˆ’ "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
24+ "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=",
28โˆ’ "owner": "hercules-ci",
25+ "owner": "nixos",
29โˆ’ "repo": "gitignore.nix",
26+ "repo": "nixpkgs",
30โˆ’ "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
27+ "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886",
31 "type": "github"
28 "type": "github"
32 },
29 },
33 "original": {
30 "original": {
34โˆ’ "owner": "hercules-ci",
31+ "owner": "nixos",
35โˆ’ "repo": "gitignore.nix",
32+ "ref": "nixpkgs-unstable",
33+ "repo": "nixpkgs",
36 "type": "github"
34 "type": "github"
37 }
35 }
38 },
36 },
39โˆ’ "nixpkgs": {
37+ "nixpkgs-ghc88": {
40 "locked": {
38 "locked": {
41โˆ’ "lastModified": 1632846328,
39+ "lastModified": 1596466290,
42โˆ’ "narHash": "sha256-sFi6YtlGK30TBB9o6CW7LG9mYHkgtKeWbSLAjjrNTX0=",
40+ "narHash": "sha256-V1vrlYfVEdW4iauUc58LCtorSxLLF+X/PhjD5+dQjeQ=",
43โˆ’ "owner": "NixOS",
41+ "owner": "nixos",
44 "repo": "nixpkgs",
42 "repo": "nixpkgs",
45โˆ’ "rev": "2b71ddd869ad592510553d09fe89c9709fa26b2b",
43+ "rev": "76f2e271a2ef9de3734dcc9d366a42d6bfb18e82",
46 "type": "github"
44 "type": "github"
47 },
45 },
48 "original": {
46 "original": {
47+ "owner": "nixos",
48+ "ref": "76f2e271a2ef",
49โˆ’ "id": "nixpkgs",
49+ "repo": "nixpkgs",
50โˆ’ "type": "indirect"
50+ "type": "github"
51 }
51 }
52 },
52 },
53 "nixpkgs-lib": {
53 "nixpkgs-lib": {
@@ -68,27 +68,11 @@
68 "type": "github"
68 "type": "github"
69 }
69 }
70 },
70 },
71โˆ’ "nixpkgs_2": {
72โˆ’ "locked": {
73โˆ’ "lastModified": 1678594102,
74โˆ’ "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=",
75โˆ’ "owner": "nixos",
76โˆ’ "repo": "nixpkgs",
77โˆ’ "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886",
78โˆ’ "type": "github"
79โˆ’ },
80โˆ’ "original": {
81โˆ’ "owner": "nixos",
82โˆ’ "ref": "nixpkgs-unstable",
83โˆ’ "repo": "nixpkgs",
84โˆ’ "type": "github"
85โˆ’ }
86โˆ’ },
87 "root": {
71 "root": {
88 "inputs": {
72 "inputs": {
89 "flake-parts": "flake-parts",
73 "flake-parts": "flake-parts",
90โˆ’ "gitignore": "gitignore",
74+ "nixpkgs": "nixpkgs",
91โˆ’ "nixpkgs": "nixpkgs_2"
75+ "nixpkgs-ghc88": "nixpkgs-ghc88"
92 }
76 }
93 }
77 }
94 },
78 },
flake.nix+13โˆ’8
@@ -1,29 +1,34 @@
1{
1{
2 inputs = {
2 inputs = {
3 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
3 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+ nixpkgs-ghc88.url = "github:nixos/nixpkgs/76f2e271a2ef";
4 flake-parts.url = "github:hercules-ci/flake-parts";
5 flake-parts.url = "github:hercules-ci/flake-parts";
5โˆ’ gitignore.url = "github:hercules-ci/gitignore.nix";
6 };
6 };
7โˆ’ outputs = inputs@{ nixpkgs, flake-parts, gitignore, ... }:
7+ outputs = inputs@{ nixpkgs, flake-parts, ... }:
8 flake-parts.lib.mkFlake { inherit inputs; } {
8 flake-parts.lib.mkFlake { inherit inputs; } {
9 systems = nixpkgs.lib.systems.flakeExposed;
9 systems = nixpkgs.lib.systems.flakeExposed;
10 perSystem = { self', inputs', pkgs, system, ... }:
10 perSystem = { self', inputs', pkgs, system, ... }:
11 let
11 let
12โˆ’ inherit (gitignore.lib) gitignoreSource;
13 overlay = self: super: {
12 overlay = self: super: {
14โˆ’ jrec = self.callCabal2nix "jrec" (gitignoreSource ./.) { };
13+ jrec = self.callCabal2nix "jrec" ./. { };
14+ };
15+ ghcVersions = {
16+ ghc88 = inputs.nixpkgs-ghc88.legacyPackages.${system}.haskellPackages.extend overlay;
17+ ghc92 = pkgs.haskellPackages.extend overlay;
15 };
18 };
16โˆ’ haskellPackages' = pkgs.haskellPackages.extend overlay;
17 in
19 in
18 {
20 {
19โˆ’ packages.default = haskellPackages'.jrec;
21+ packages.default = ghcVersions.ghc92.jrec;
20โˆ’ devShells.default = haskellPackages'.shellFor {
22+ devShells.default = ghcVersions.ghc92.shellFor {
21 packages = p: [ p.jrec ];
23 packages = p: [ p.jrec ];
22โˆ’ buildInputs = with haskellPackages'; [
24+ buildInputs = with ghcVersions.ghc92; [
23 cabal-install
25 cabal-install
26+ ghcid
24 haskell-language-server
27 haskell-language-server
25 ];
28 ];
26 };
29 };
30+ # Expose jrec built with GHC 8.8 so it can be tested in CI.
31+ packages.jrec-ghc88 = ghcVersions.ghc88.jrec;
27 };
32 };
28 };
33 };
29}
34}
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,