on master help sign in
With(out) generic flag
commitdff2daf67e2d4b4fd4970567b50026fc112041af authorAlexander V. Nikolaev <avn@avnik.info> dateSun 17 Apr 2022, 17:45 (4 years ago) parent94ab29f
2 files changed+13−1
jrec.cabal+10−1 src/JRec.hs+3
jrec.cabal+10−1
@@ -24,6 +24,13 @@ flag with-aeson
2424 -- with instances by default
2525 default: True
2626
27+flag with-generics
28+ description: Enable GHC.Generics instances
29+ -- don't let the solver fiddle with the flag
30+ manual: True
31+ -- with instances by default
32+ default: True
33+
2734-- A common stanza to share with tests, so that ghcid (bin/test) will reload
2835-- instantly when the library sources change (without us having to restart it).
2936common library-common
@@ -81,13 +88,15 @@ library
8188 JRec.Field
8289 if flag(with-aeson)
8390 cpp-options: -DWITH_AESON
91+ if flag(with-generics)
92+ cpp-options: -DWITH_GENERICS
8493
8594test-suite jrec-test
8695 import: library-common
8796 type: exitcode-stdio-1.0
8897 hs-source-dirs: test, src
8998 main-is: Spec.hs
90− cpp-options: -DWITH_AESON
99+ cpp-options: -DWITH_AESON -DWITH_GENERICS
91100 build-depends:
92101 base,
93102 hspec,
src/JRec.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE GADTs #-}
23{-# LANGUAGE PatternSynonyms #-}
34{-# LANGUAGE TypeApplications #-}
@@ -128,6 +129,7 @@ type RecordRep fields =
128129 (Sels fields)
129130 )
130131
132+#ifdef WITH_GENERICS
131133instance
132134 (R.FromNative (RecordRep fields) fields, R.ToNative (RecordRep fields) fields) =>
133135 Generic (Rec fields)
@@ -137,6 +139,7 @@ instance
137139 RecordRep fields
138140 from r = R.toNative' r
139141 to rep = R.fromNative' rep
142+#endif
140143
141144----------------------------------------------------------------------------
142145-- generic-lens