on master help sign in
Add flag with-aeson to enable/disable aeson instances
commitb149883e4c9aacf196ef0326b8e029930b5f2325 authorkana-sama <andrew4chrome@gmail.com> dateThu 3 Sep 2020, 15:55 (6 years ago) parent588247b
2 files changed+12
jrec.cabal+9 src/JRec/Internal.hs+3
jrec.cabal+9
@@ -17,6 +17,13 @@ extra-source-files:
1717 CHANGELOG.md
1818 README.md
1919
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+
2027-- A common stanza to share with tests, so that ghcid (bin/test) will reload
2128-- instantly when the library sources change (without us having to restart it).
2229common library-common
@@ -72,6 +79,8 @@ library
7279 other-modules:
7380 JRec.Tuple
7481 JRec.Field
82+ if flag(with-aeson)
83+ cpp-options: -DWITH_AESON
7584
7685test-suite jrec-test
7786 import: library-common
src/JRec/Internal.hs+3
@@ -1,4 +1,5 @@
11{-# LANGUAGE BangPatterns #-}
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE ConstraintKinds #-}
34{-# LANGUAGE DataKinds #-}
45{-# LANGUAGE ExistentialQuantification #-}
@@ -108,6 +109,7 @@ instance RecEq lts lts => Eq (Rec lts) where
108109 (==) (a :: Rec lts) (b :: Rec lts) = recEq a b (Proxy :: Proxy lts)
109110 {-# INLINE (==) #-}
110111
112+#if WITH_AESON
111113instance
112114 ( RecApply lts lts ToJSON
113115 ) =>
@@ -118,6 +120,7 @@ instance
118120
119121instance (RecSize lts ~ s, KnownNat s, RecJsonParse lts) => FromJSON (Rec lts) where
120122 parseJSON = recJsonParser defaultJSONOptions
123+#endif
121124
122125instance RecNfData lts lts => NFData (Rec lts) where
123126 rnf = recNfData (Proxy :: Proxy lts)