on master help sign in
13 files changed+83−130
since splitsnapshots
unifiedsplit
.github/workflows/ci.yaml+7−13 .vscode/extensions.json+11 .vscode/settings.json+5−4 CHANGELOG.md+4 Setup.hs−2 bin/test+1−1 default.nix−36 flake.lock+20−36 flake.nix+13−16 hie.yaml+5−16 jrec.cabal+3 shell.nix+1 src/JRec/Internal.hs+13−6
.github/workflows/ci.yaml+7−13
@@ -4,20 +4,14 @@ on:
44 push:
55jobs:
66 build:
7− runs-on: ${{ matrix.os }}
8− strategy:
9− matrix:
10− ghc: ['ghc884', 'ghc8101']
11− os: [ubuntu-latest]
12− name: GHC ${{ matrix.ghc }}
7+ runs-on: ubuntu-latest
138 steps:
149 - uses: actions/checkout@v2
15− - uses: cachix/install-nix-action@v10
16− - uses: cachix/cachix-action@v6
10+ - uses: nixbuild/nix-quick-install-action@v21
1711 with:
18− name: juspay-nau
19− signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
20− # Only needed for private caches
21− authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
12+ nix_conf: |
13+ experimental-features = nix-command flakes
2214 - name: Build and test 🔧
23− run: nix-build -j4 --argstr compiler ${{ matrix.ghc }}
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 @@
11{
2− "nixEnvSelector.nixShellConfig": "${workspaceRoot}/default.nix",
3− "editor.formatOnType": true,
4− "editor.formatOnSave": true
5−}
2+ "editor.formatOnType": true,
3+ "editor.formatOnSave": true,
4+ "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
5+ "haskell.manageHLS": "PATH"
6+}
CHANGELOG.md+4
@@ -1,5 +1,9 @@
11# Revision history for rec
22
3+## Unreleased
4+
5+- GHC 9.2 + Aeson 2.0 support
6+
37## 0.1.0.0 -- YYYY-mm-dd
48
59* First version. Released on an unsuspecting world.
Setup.hsdeleted−2
@@ -1,2 +0,0 @@
1−import Distribution.Simple
2−main = defaultMain
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-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 @@
1818 "type": "github"
1919 }
2020 },
21− "gitignore": {
22− "inputs": {
23− "nixpkgs": "nixpkgs"
24− },
21+ "nixpkgs": {
2522 "locked": {
26− "lastModified": 1660459072,
27− "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
28− "owner": "hercules-ci",
29− "repo": "gitignore.nix",
30− "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
23+ "lastModified": 1678594102,
24+ "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=",
25+ "owner": "nixos",
26+ "repo": "nixpkgs",
27+ "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886",
3128 "type": "github"
3229 },
3330 "original": {
34− "owner": "hercules-ci",
35− "repo": "gitignore.nix",
31+ "owner": "nixos",
32+ "ref": "nixpkgs-unstable",
33+ "repo": "nixpkgs",
3634 "type": "github"
3735 }
3836 },
39− "nixpkgs": {
37+ "nixpkgs-ghc88": {
4038 "locked": {
41− "lastModified": 1632846328,
42− "narHash": "sha256-sFi6YtlGK30TBB9o6CW7LG9mYHkgtKeWbSLAjjrNTX0=",
43− "owner": "NixOS",
39+ "lastModified": 1596466290,
40+ "narHash": "sha256-V1vrlYfVEdW4iauUc58LCtorSxLLF+X/PhjD5+dQjeQ=",
41+ "owner": "nixos",
4442 "repo": "nixpkgs",
45− "rev": "2b71ddd869ad592510553d09fe89c9709fa26b2b",
43+ "rev": "76f2e271a2ef9de3734dcc9d366a42d6bfb18e82",
4644 "type": "github"
4745 },
4846 "original": {
49− "id": "nixpkgs",
50− "type": "indirect"
47+ "owner": "nixos",
48+ "ref": "76f2e271a2ef",
49+ "repo": "nixpkgs",
50+ "type": "github"
5151 }
5252 },
5353 "nixpkgs-lib": {
@@ -68,27 +68,11 @@
6868 "type": "github"
6969 }
7070 },
71− "nixpkgs_2": {
72− "locked": {
73− "lastModified": 1678500213,
74− "narHash": "sha256-A5s2rXawJ+dCThkMXoMuYW8dgyUmkElcyfVJUot/Vr0=",
75− "owner": "nixos",
76− "repo": "nixpkgs",
77− "rev": "2ce9b9842b5e63884dfc3dea6689769e2a1ea309",
78− "type": "github"
79− },
80− "original": {
81− "owner": "nixos",
82− "ref": "nixpkgs-unstable",
83− "repo": "nixpkgs",
84− "type": "github"
85− }
86− },
8771 "root": {
8872 "inputs": {
8973 "flake-parts": "flake-parts",
90− "gitignore": "gitignore",
91− "nixpkgs": "nixpkgs_2"
74+ "nixpkgs": "nixpkgs",
75+ "nixpkgs-ghc88": "nixpkgs-ghc88"
9276 }
9377 }
9478 },
flake.nix+13−16
@@ -1,37 +1,34 @@
11{
22 inputs = {
33 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+ nixpkgs-ghc88.url = "github:nixos/nixpkgs/76f2e271a2ef";
45 flake-parts.url = "github:hercules-ci/flake-parts";
5− gitignore.url = "github:hercules-ci/gitignore.nix";
66 };
7− outputs = inputs@{ nixpkgs, flake-parts, gitignore, ... }:
7+ outputs = inputs@{ nixpkgs, flake-parts, ... }:
88 flake-parts.lib.mkFlake { inherit inputs; } {
99 systems = nixpkgs.lib.systems.flakeExposed;
1010 perSystem = { self', inputs', pkgs, system, ... }:
1111 let
12− inherit (gitignore.lib) gitignoreSource;
13− fixCyclicReference = drv:
14− pkgs.haskell.lib.overrideCabal drv (_: {
15− enableSeparateBinOutput = false;
16− });
1712 overlay = self: super: {
18− jrec = self.callCabal2nix "jrec" (gitignoreSource ./.) { };
19− # Workaround for https://github.com/NixOS/nixpkgs/issues/140774
20− haskell-language-server = super.haskell-language-server.overrideScope (lself: lsuper: {
21− ormolu = fixCyclicReference super.ormolu;
22− });
13+ jrec = self.callCabal2nix "jrec" ./. { };
14+ };
15+ ghcVersions = {
16+ ghc88 = inputs.nixpkgs-ghc88.legacyPackages.${system}.haskellPackages.extend overlay;
17+ ghc92 = pkgs.haskellPackages.extend overlay;
2318 };
24− haskellPackages' = pkgs.haskellPackages.extend overlay;
2519 in
2620 {
27− packages.default = haskellPackages'.jrec;
28− devShells.default = haskellPackages'.shellFor {
21+ packages.default = ghcVersions.ghc92.jrec;
22+ devShells.default = ghcVersions.ghc92.shellFor {
2923 packages = p: [ p.jrec ];
30− buildInputs = with haskellPackages'; [
24+ buildInputs = with ghcVersions.ghc92; [
3125 cabal-install
26+ ghcid
3227 haskell-language-server
3328 ];
3429 };
30+ # Expose jrec built with GHC 8.8 so it can be tested in CI.
31+ packages.jrec-ghc88 = ghcVersions.ghc88.jrec;
3532 };
3633 };
3734}
hie.yaml+5−16
@@ -1,17 +1,6 @@
11cradle:
2− multi:
3− - path: ./Setup.hs
4− config:
5− cradle:
6− direct:
7− arguments:
8− - "-package Cabal"
9− - "-package base"
10− - path: ./
11− config:
12− cradle:
13− cabal:
14− - path: "./src"
15− component: "lib:jrec"
16− - path: "./test"
17− component: "test:jrec-test"
2+ cabal:
3+ - path: "./src"
4+ component: "lib:jrec"
5+ - path: "./test"
6+ component: "test:jrec-test"
jrec.cabal+3
@@ -97,6 +97,9 @@ test-suite jrec-test
9797 hs-source-dirs: test, src
9898 main-is: Spec.hs
9999 cpp-options: -DWITH_AESON -DWITH_GENERICS
100+ other-modules:
101+ JRecShouldNotTypecheckSpec
102+ JRecSpec
100103 build-depends:
101104 base,
102105 hspec,
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
4646import qualified Optics.Lens as OL
4747import Unsafe.Coerce
4848import Prelude
49−import qualified Data.Aeson.Key as Key
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
5057
5158-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
5259-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -559,16 +566,16 @@ class ToJSON a => EncodeField a where
559566
560567instance ToJSON a => EncodeField a where
561568 encodeField = pure . toJSON
562− encodeKV k v = Key.fromText k .= v
569+ encodeKV k v = fromText k .= v
563570
564571instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
565572 encodeField = fmap toJSON
566573 encodeKV _ Nothing = mempty
567− encodeKV k v = Key.fromText k .= v
574+ encodeKV k v = fromText k .= v
568575
569576recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
570577recToValue 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
572579
573580recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
574581recToEncoding options r =
@@ -673,10 +680,10 @@ class FromJSON a => ParseField a where
673680 parseField :: Object -> T.Text -> Parser a
674681
675682instance FromJSON a => ParseField a where
676− parseField o k = o .: Key.fromText k
683+ parseField o k = o .: fromText k
677684
678685instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
679− parseField o k = o .:? Key.fromText k
686+ parseField o k = o .:? fromText k
680687
681688instance
682689 ( KnownSymbol l,