on master help sign in
Add flag with-aeson to enable/disable aeson instances
b149883kana-sama
jrec.cabal+9
@@ -17,6 +17,13 @@ extra-source-files:
17 CHANGELOG.md
17 CHANGELOG.md
18 README.md
18 README.md
19
19
20+flag with-aeson
21+ description: Enable Aeson instances
22+ -- don't let the solver fiddle with the flag
23+ manual: True
24+ -- with instances by default
25+ default: True
26+
20-- A common stanza to share with tests, so that ghcid (bin/test) will reload
27-- A common stanza to share with tests, so that ghcid (bin/test) will reload
21-- instantly when the library sources change (without us having to restart it).
28-- instantly when the library sources change (without us having to restart it).
22common library-common
29common library-common
@@ -72,6 +79,8 @@ library
72 other-modules:
79 other-modules:
73 JRec.Tuple
80 JRec.Tuple
74 JRec.Field
81 JRec.Field
82+ if flag(with-aeson)
83+ cpp-options: -DWITH_AESON
75
84
76test-suite jrec-test
85test-suite jrec-test
77 import: library-common
86 import: library-common
src/JRec/Internal.hs+3
@@ -1,4 +1,5 @@
1{-# LANGUAGE BangPatterns #-}
1{-# LANGUAGE BangPatterns #-}
2+{-# LANGUAGE CPP #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE ExistentialQuantification #-}
5{-# LANGUAGE ExistentialQuantification #-}
@@ -108,6 +109,7 @@ instance RecEq lts lts => Eq (Rec lts) where
108 (==) (a :: Rec lts) (b :: Rec lts) = recEq a b (Proxy :: Proxy lts)
109 (==) (a :: Rec lts) (b :: Rec lts) = recEq a b (Proxy :: Proxy lts)
109 {-# INLINE (==) #-}
110 {-# INLINE (==) #-}
110
111
112+#if WITH_AESON
111instance
113instance
112 ( RecApply lts lts ToJSON
114 ( RecApply lts lts ToJSON
113 ) =>
115 ) =>
@@ -118,6 +120,7 @@ instance
118
120
119instance (RecSize lts ~ s, KnownNat s, RecJsonParse lts) => FromJSON (Rec lts) where
121instance (RecSize lts ~ s, KnownNat s, RecJsonParse lts) => FromJSON (Rec lts) where
120 parseJSON = recJsonParser defaultJSONOptions
122 parseJSON = recJsonParser defaultJSONOptions
123+#endif
121
124
122instance RecNfData lts lts => NFData (Rec lts) where
125instance RecNfData lts lts => NFData (Rec lts) where
123 rnf = recNfData (Proxy :: Proxy lts)
126 rnf = recNfData (Proxy :: Proxy lts)