on master help sign in
Merge pull request #28 from abshekh/master
44f2459Sridhar Ratnakumar
.github/workflows/ci.yaml+5−13
@@ -4,20 +4,12 @@ on:
4 push:
4 push:
5jobs:
5jobs:
6 build:
6 build:
7− runs-on: ${{ matrix.os }}
8− strategy:
9− matrix:
10− ghc: ['ghc884', 'ghc8101']
11− os: [ubuntu-latest]
7+ runs-on: ubuntu-latest
12− name: GHC ${{ matrix.ghc }}
13 steps:
8 steps:
14 - uses: actions/checkout@v2
9 - uses: actions/checkout@v2
15− - uses: cachix/install-nix-action@v10
10+ - uses: nixbuild/nix-quick-install-action@v21
16− - uses: cachix/cachix-action@v6
17 with:
11 with:
18− name: juspay-nau
12+ nix_conf: |
19− signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
13+ experimental-features = nix-command flakes
20− # Only needed for private caches
21− authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
22 - name: Build and test 🔧
14 - name: Build and test 🔧
23− run: nix-build -j4 --argstr compiler ${{ matrix.ghc }}
15+ run: nix build -j 4 -L
Setup.hsdeleted−2
@@ -1,2 +0,0 @@
1−import Distribution.Simple
2−main = defaultMain
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.locknew file+64
@@ -0,0 +1,64 @@
1+{
2+ "nodes": {
3+ "flake-parts": {
4+ "inputs": {
5+ "nixpkgs-lib": "nixpkgs-lib"
6+ },
7+ "locked": {
8+ "lastModified": 1678379998,
9+ "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=",
10+ "owner": "hercules-ci",
11+ "repo": "flake-parts",
12+ "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447",
13+ "type": "github"
14+ },
15+ "original": {
16+ "owner": "hercules-ci",
17+ "repo": "flake-parts",
18+ "type": "github"
19+ }
20+ },
21+ "nixpkgs": {
22+ "locked": {
23+ "lastModified": 1678594102,
24+ "narHash": "sha256-OHAHYiMWJFPNxuW/PcOMlSD2tvXnEYC1jxREBADHwwQ=",
25+ "owner": "nixos",
26+ "repo": "nixpkgs",
27+ "rev": "796b4a3c1d903c4b9270cd2548fe46f524eeb886",
28+ "type": "github"
29+ },
30+ "original": {
31+ "owner": "nixos",
32+ "ref": "nixpkgs-unstable",
33+ "repo": "nixpkgs",
34+ "type": "github"
35+ }
36+ },
37+ "nixpkgs-lib": {
38+ "locked": {
39+ "dir": "lib",
40+ "lastModified": 1678375444,
41+ "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=",
42+ "owner": "NixOS",
43+ "repo": "nixpkgs",
44+ "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e",
45+ "type": "github"
46+ },
47+ "original": {
48+ "dir": "lib",
49+ "owner": "NixOS",
50+ "ref": "nixos-unstable",
51+ "repo": "nixpkgs",
52+ "type": "github"
53+ }
54+ },
55+ "root": {
56+ "inputs": {
57+ "flake-parts": "flake-parts",
58+ "nixpkgs": "nixpkgs"
59+ }
60+ }
61+ },
62+ "root": "root",
63+ "version": 7
64+}
flake.nixnew file+27
@@ -0,0 +1,27 @@
1+{
2+ inputs = {
3+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+ flake-parts.url = "github:hercules-ci/flake-parts";
5+ };
6+ outputs = inputs@{ nixpkgs, flake-parts, ... }:
7+ flake-parts.lib.mkFlake { inherit inputs; } {
8+ systems = nixpkgs.lib.systems.flakeExposed;
9+ perSystem = { self', inputs', pkgs, system, ... }:
10+ let
11+ overlay = self: super: {
12+ jrec = self.callCabal2nix "jrec" ./. { };
13+ };
14+ haskellPackages' = pkgs.haskellPackages.extend overlay;
15+ in
16+ {
17+ packages.default = haskellPackages'.jrec;
18+ devShells.default = haskellPackages'.shellFor {
19+ packages = p: [ p.jrec ];
20+ buildInputs = with haskellPackages'; [
21+ cabal-install
22+ haskell-language-server
23+ ];
24+ };
25+ };
26+ };
27+}
jrec.cabal+4−1
@@ -37,7 +37,7 @@ common library-common
37 default-language: Haskell2010
37 default-language: Haskell2010
38 build-depends:
38 build-depends:
39 aeson
39 aeson
40− , base >=4.13 && <4.15
40+ , base >=4.13 && <4.17
41 , constraints
41 , constraints
42 , deepseq
42 , deepseq
43 , generic-data
43 , generic-data
@@ -97,6 +97,9 @@ test-suite jrec-test
97 hs-source-dirs: test, src
97 hs-source-dirs: test, src
98 main-is: Spec.hs
98 main-is: Spec.hs
99 cpp-options: -DWITH_AESON -DWITH_GENERICS
99 cpp-options: -DWITH_AESON -DWITH_GENERICS
100+ other-modules:
101+ JRecShouldNotTypecheckSpec
102+ JRecSpec
100 build-depends:
103 build-depends:
101 base,
104 base,
102 hspec,
105 hspec,
src/JRec/Internal.hs+6−5
@@ -46,6 +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+import qualified Data.Aeson.Key as Key
49
50
50-- | 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.
51-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
52-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -558,16 +559,16 @@ class ToJSON a => EncodeField a where
558
559
559instance ToJSON a => EncodeField a where
560instance ToJSON a => EncodeField a where
560 encodeField = pure . toJSON
561 encodeField = pure . toJSON
561− encodeKV = (.=)
562+ encodeKV k v = Key.fromText k .= v
562
563
563instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
564 encodeField = fmap toJSON
565 encodeField = fmap toJSON
565 encodeKV _ Nothing = mempty
566 encodeKV _ Nothing = mempty
566− encodeKV k v = k .= v
567+ encodeKV k v = Key.fromText k .= v
567
568
568recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
569recToValue options r =
570recToValue options r =
570− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (T.pack (fieldTransform options k),) <$> encodeField v) r
571+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (Key.fromString (fieldTransform options k),) <$> encodeField v) r
571
572
572recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
573recToEncoding options r =
574recToEncoding options r =
@@ -672,10 +673,10 @@ class FromJSON a => ParseField a where
672 parseField :: Object -> T.Text -> Parser a
673 parseField :: Object -> T.Text -> Parser a
673
674
674instance FromJSON a => ParseField a where
675instance FromJSON a => ParseField a where
675− parseField = (.:)
676+ parseField o k = o .: Key.fromText k
676
677
677instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
678− parseField = (.:?)
679+ parseField o k = o .:? Key.fromText k
679
680
680instance
681instance
681 ( KnownSymbol l,
682 ( KnownSymbol l,