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+18โˆ’1
@@ -34,6 +34,22 @@
34 "type": "github"
34 "type": "github"
35 }
35 }
36 },
36 },
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+ },
37 "nixpkgs-lib": {
53 "nixpkgs-lib": {
38 "locked": {
54 "locked": {
39 "dir": "lib",
55 "dir": "lib",
@@ -55,7 +71,8 @@
55 "root": {
71 "root": {
56 "inputs": {
72 "inputs": {
57 "flake-parts": "flake-parts",
73 "flake-parts": "flake-parts",
58โˆ’ "nixpkgs": "nixpkgs"
74+ "nixpkgs": "nixpkgs",
75+ "nixpkgs-ghc88": "nixpkgs-ghc88"
59 }
76 }
60 }
77 }
61 },
78 },
flake.nix+11โˆ’4
@@ -1,6 +1,7 @@
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 };
6 };
6 outputs = inputs@{ nixpkgs, flake-parts, ... }:
7 outputs = inputs@{ nixpkgs, flake-parts, ... }:
@@ -11,17 +12,23 @@
11 overlay = self: super: {
12 overlay = self: super: {
12 jrec = self.callCabal2nix "jrec" ./. { };
13 jrec = self.callCabal2nix "jrec" ./. { };
13 };
14 };
15+ ghcVersions = {
16+ ghc88 = inputs.nixpkgs-ghc88.legacyPackages.${system}.haskellPackages.extend overlay;
14โˆ’ haskellPackages' = pkgs.haskellPackages.extend overlay;
17+ ghc92 = pkgs.haskellPackages.extend overlay;
18+ };
15 in
19 in
16 {
20 {
17โˆ’ packages.default = haskellPackages'.jrec;
21+ packages.default = ghcVersions.ghc92.jrec;
18โˆ’ devShells.default = haskellPackages'.shellFor {
22+ devShells.default = ghcVersions.ghc92.shellFor {
19 packages = p: [ p.jrec ];
23 packages = p: [ p.jrec ];
20โˆ’ buildInputs = with haskellPackages'; [
24+ buildInputs = with ghcVersions.ghc92; [
21 cabal-install
25 cabal-install
26+ ghcid
22 haskell-language-server
27 haskell-language-server
23 ];
28 ];
24 };
29 };
30+ # Expose jrec built with GHC 8.8 so it can be tested in CI.
31+ packages.jrec-ghc88 = ghcVersions.ghc88.jrec;
25 };
32 };
26 };
33 };
27}
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,