on 44f2459 help sign in
.github/workflows/ci.yamlโˆ’2
since splitsnapshots
unifiedsplit
@@ -13,5 +13,3 @@ 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.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 @@
1{
1{
2โˆ’ "editor.formatOnType": true,
3โˆ’ "editor.formatOnSave": true,
4โˆ’ "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
2+ "nixEnvSelector.nixShellConfig": "${workspaceRoot}/default.nix",
5โˆ’ "haskell.manageHLS": "PATH"
3+ "editor.formatOnType": true,
4+ "editor.formatOnSave": true
6โˆ’}
5+}
CHANGELOG.mdโˆ’4
@@ -1,9 +1,5 @@
1# Revision history for rec
1# Revision history for rec
2
2
3โˆ’## Unreleased
4โˆ’
5โˆ’- GHC 9.2 + Aeson 2.0 support
6โˆ’
7## 0.1.0.0 -- YYYY-mm-dd
3## 0.1.0.0 -- YYYY-mm-dd
8
4
9* First version. Released on an unsuspecting world.
5* 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 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 @@
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โˆ’ },
53 "nixpkgs-lib": {
37 "nixpkgs-lib": {
54 "locked": {
38 "locked": {
55 "dir": "lib",
39 "dir": "lib",
@@ -71,8 +55,7 @@
71 "root": {
55 "root": {
72 "inputs": {
56 "inputs": {
73 "flake-parts": "flake-parts",
57 "flake-parts": "flake-parts",
74โˆ’ "nixpkgs": "nixpkgs",
58+ "nixpkgs": "nixpkgs"
75โˆ’ "nixpkgs-ghc88": "nixpkgs-ghc88"
76 }
59 }
77 }
60 }
78 },
61 },
flake.nix+4โˆ’11
@@ -1,7 +1,6 @@
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";
5 flake-parts.url = "github:hercules-ci/flake-parts";
4 flake-parts.url = "github:hercules-ci/flake-parts";
6 };
5 };
7 outputs = inputs@{ nixpkgs, flake-parts, ... }:
6 outputs = inputs@{ nixpkgs, flake-parts, ... }:
@@ -12,23 +11,17 @@
12 overlay = self: super: {
11 overlay = self: super: {
13 jrec = self.callCabal2nix "jrec" ./. { };
12 jrec = self.callCabal2nix "jrec" ./. { };
14 };
13 };
15โˆ’ ghcVersions = {
16โˆ’ ghc88 = inputs.nixpkgs-ghc88.legacyPackages.${system}.haskellPackages.extend overlay;
17โˆ’ ghc92 = pkgs.haskellPackages.extend overlay;
14+ haskellPackages' = pkgs.haskellPackages.extend overlay;
18โˆ’ };
19 in
15 in
20 {
16 {
21โˆ’ packages.default = ghcVersions.ghc92.jrec;
17+ packages.default = haskellPackages'.jrec;
22โˆ’ devShells.default = ghcVersions.ghc92.shellFor {
18+ devShells.default = haskellPackages'.shellFor {
23 packages = p: [ p.jrec ];
19 packages = p: [ p.jrec ];
24โˆ’ buildInputs = with ghcVersions.ghc92; [
20+ buildInputs = with haskellPackages'; [
25 cabal-install
21 cabal-install
26โˆ’ ghcid
27 haskell-language-server
22 haskell-language-server
28 ];
23 ];
29 };
24 };
30โˆ’ # Expose jrec built with GHC 8.8 so it can be tested in CI.
31โˆ’ packages.jrec-ghc88 = ghcVersions.ghc88.jrec;
32 };
25 };
33 };
26 };
34}
27}
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
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)
50โˆ’import Data.Aeson.Key (fromText, fromString)
49+import qualified Data.Aeson.Key as Key
51โˆ’#else
52โˆ’fromText :: a -> a
53โˆ’fromText = id
54โˆ’fromString :: String -> T.Text
55โˆ’fromString = T.pack
56โˆ’#endif
57
50
58-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
51-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
59-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
52-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -566,16 +559,16 @@ class ToJSON a => EncodeField a where
566
559
567instance ToJSON a => EncodeField a where
560instance ToJSON a => EncodeField a where
568 encodeField = pure . toJSON
561 encodeField = pure . toJSON
569โˆ’ encodeKV k v = fromText k .= v
562+ encodeKV k v = Key.fromText k .= v
570
563
571instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
572 encodeField = fmap toJSON
565 encodeField = fmap toJSON
573 encodeKV _ Nothing = mempty
566 encodeKV _ Nothing = mempty
574โˆ’ encodeKV k v = fromText k .= v
567+ encodeKV k v = Key.fromText k .= v
575
568
576recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
577recToValue options r =
570recToValue 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
579
572
580recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
581recToEncoding options r =
574recToEncoding options r =
@@ -680,10 +673,10 @@ class FromJSON a => ParseField a where
680 parseField :: Object -> T.Text -> Parser a
673 parseField :: Object -> T.Text -> Parser a
681
674
682instance FromJSON a => ParseField a where
675instance FromJSON a => ParseField a where
683โˆ’ parseField o k = o .: fromText k
676+ parseField o k = o .: Key.fromText k
684
677
685instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
686โˆ’ parseField o k = o .:? fromText k
679+ parseField o k = o .:? Key.fromText k
687
680
688instance
681instance
689 ( KnownSymbol l,
682 ( KnownSymbol l,