on master help sign in
Make support for GHC generics unconditional
commit1dbff80c2254fd8713dd96b8790fb265106a2a09 authorBryan O'Sullivan <bos@serpentine.com> dateMon 25 May 2015, 12:58 (11 years ago) parent12ab143
5 files changed+5−31
Data/Aeson.hs+1−2 Data/Aeson/Types.hs+1−8 Data/Aeson/Types/Class.hs+1−14 Data/Aeson/Types/Instances.hs+2−6 aeson.cabal−1
Data/Aeson.hs+1−2
@@ -56,13 +56,12 @@ module Data.Aeson
5656 , Result(..)
5757 , fromJSON
5858 , ToJSON(..)
59−#ifdef GENERICS
6059 -- ** Generic JSON classes
6160 , GFromJSON(..)
6261 , GToJSON(..)
6362 , genericToJSON
6463 , genericParseJSON
65−#endif
64+
6665 -- * Inspecting @'Value's@
6766 , withObject
6867 , withText
Data/Aeson/Types.hs+1−8
@@ -1,5 +1,3 @@
1−{-# LANGUAGE CPP #-}
2−
31-- |
42-- Module: Data.Aeson.Types
53-- Copyright: (c) 2011, 2012 Bryan O'Sullivan
@@ -34,13 +32,11 @@ module Data.Aeson.Types
3432 , ToJSON(..)
3533 , modifyFailure
3634
37−#ifdef GENERICS
3835 -- ** Generic JSON classes
3936 , GFromJSON(..)
4037 , GToJSON(..)
4138 , genericToJSON
4239 , genericParseJSON
43−#endif
4440
4541 -- * Inspecting @'Value's@
4642 , withObject
@@ -65,9 +61,6 @@ module Data.Aeson.Types
6561 , defaultTaggedObject
6662 ) where
6763
64+import Data.Aeson.Types.Generic ()
6865import Data.Aeson.Types.Instances
6966import Data.Aeson.Types.Internal
70−
71−#ifdef GENERICS
72−import Data.Aeson.Types.Generic ()
73−#endif
Data/Aeson/Types/Class.hs+1−14
@@ -1,8 +1,4 @@
1−{-# LANGUAGE CPP, FlexibleContexts #-}
2−
3−#ifdef GENERICS
4−{-# LANGUAGE DefaultSignatures #-}
5−#endif
1+{-# LANGUAGE DefaultSignatures, FlexibleContexts #-}
62
73-- |
84-- Module: Data.Aeson.Types.Class
@@ -21,18 +17,14 @@ module Data.Aeson.Types.Class
2117 -- ** Core JSON classes
2218 FromJSON(..)
2319 , ToJSON(..)
24−#ifdef GENERICS
2520 -- ** Generic JSON classes
2621 , GFromJSON(..)
2722 , GToJSON(..)
2823 , genericToJSON
2924 , genericParseJSON
30−#endif
3125 ) where
3226
3327import Data.Aeson.Types.Internal
34−
35−#ifdef GENERICS
3628import GHC.Generics
3729
3830-- | Class of generic representation types ('Rep') that can be converted to JSON.
@@ -58,7 +50,6 @@ genericToJSON opts = gToJSON opts . from
5850-- type is an instance of 'Generic'.
5951genericParseJSON :: (Generic a, GFromJSON (Rep a)) => Options -> Value -> Parser a
6052genericParseJSON opts = fmap to . gParseJSON opts
61−#endif
6253
6354-- | A type that can be converted to JSON.
6455--
@@ -115,10 +106,8 @@ genericParseJSON opts = fmap to . gParseJSON opts
115106class ToJSON a where
116107 toJSON :: a -> Value
117108
118−#ifdef GENERICS
119109 default toJSON :: (Generic a, GToJSON (Rep a)) => a -> Value
120110 toJSON = genericToJSON defaultOptions
121−#endif
122111
123112-- | A type that can be converted from JSON, with the possibility of
124113-- failure.
@@ -188,7 +177,5 @@ class ToJSON a where
188177class FromJSON a where
189178 parseJSON :: Value -> Parser a
190179
191−#ifdef GENERICS
192180 default parseJSON :: (Generic a, GFromJSON (Rep a)) => Value -> Parser a
193181 parseJSON = genericParseJSON defaultOptions
194−#endif
Data/Aeson/Types/Instances.hs+2−6
@@ -1,11 +1,8 @@
11{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
22 GeneralizedNewtypeDeriving, IncoherentInstances, OverlappingInstances,
33 OverloadedStrings, UndecidableInstances, ViewPatterns #-}
4−{-# OPTIONS_GHC -fno-warn-orphans #-}
5−
6−#ifdef GENERICS
74{-# LANGUAGE DefaultSignatures #-}
8−#endif
5+{-# OPTIONS_GHC -fno-warn-orphans #-}
96
107-- TODO: Drop this when we remove support for Data.Attoparsec.Number
118#if MIN_VERSION_attoparsec(0,12,0)
@@ -29,13 +26,12 @@ module Data.Aeson.Types.Instances
2926 -- ** Core JSON classes
3027 FromJSON(..)
3128 , ToJSON(..)
32−#ifdef GENERICS
3329 -- ** Generic JSON classes
3430 , GFromJSON(..)
3531 , GToJSON(..)
3632 , genericToJSON
3733 , genericParseJSON
38−#endif
34+
3935 -- * Types
4036 , DotNetTime(..)
4137
aeson.cabal−1
@@ -126,7 +126,6 @@ library
126126 ghc-prof-options: -auto-all
127127
128128 ghc-options: -O2 -Wall
129− cpp-options: -DGENERICS
130129
131130test-suite tests
132131 type: exitcode-stdio-1.0