on master help sign in
Make support for GHC generics unconditional
1dbff80Bryan O'Sullivan
Data/Aeson.hs+1−2
@@ -56,13 +56,12 @@ module Data.Aeson
56 , Result(..)
56 , Result(..)
57 , fromJSON
57 , fromJSON
58 , ToJSON(..)
58 , ToJSON(..)
59−#ifdef GENERICS
60 -- ** Generic JSON classes
59 -- ** Generic JSON classes
61 , GFromJSON(..)
60 , GFromJSON(..)
62 , GToJSON(..)
61 , GToJSON(..)
63 , genericToJSON
62 , genericToJSON
64 , genericParseJSON
63 , genericParseJSON
65−#endif
64+
66 -- * Inspecting @'Value's@
65 -- * Inspecting @'Value's@
67 , withObject
66 , withObject
68 , withText
67 , withText
Data/Aeson/Types.hs+1−8
@@ -1,5 +1,3 @@
1−{-# LANGUAGE CPP #-}
2−
3-- |
1-- |
4-- Module: Data.Aeson.Types
2-- Module: Data.Aeson.Types
5-- Copyright: (c) 2011, 2012 Bryan O'Sullivan
3-- Copyright: (c) 2011, 2012 Bryan O'Sullivan
@@ -34,13 +32,11 @@ module Data.Aeson.Types
34 , ToJSON(..)
32 , ToJSON(..)
35 , modifyFailure
33 , modifyFailure
36
34
37−#ifdef GENERICS
38 -- ** Generic JSON classes
35 -- ** Generic JSON classes
39 , GFromJSON(..)
36 , GFromJSON(..)
40 , GToJSON(..)
37 , GToJSON(..)
41 , genericToJSON
38 , genericToJSON
42 , genericParseJSON
39 , genericParseJSON
43−#endif
44
40
45 -- * Inspecting @'Value's@
41 -- * Inspecting @'Value's@
46 , withObject
42 , withObject
@@ -65,9 +61,6 @@ module Data.Aeson.Types
65 , defaultTaggedObject
61 , defaultTaggedObject
66 ) where
62 ) where
67
63
64+import Data.Aeson.Types.Generic ()
68import Data.Aeson.Types.Instances
65import Data.Aeson.Types.Instances
69import Data.Aeson.Types.Internal
66import 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 #-}
1+{-# LANGUAGE DefaultSignatures, FlexibleContexts #-}
2−
3−#ifdef GENERICS
4−{-# LANGUAGE DefaultSignatures #-}
5−#endif
6
2
7-- |
3-- |
8-- Module: Data.Aeson.Types.Class
4-- Module: Data.Aeson.Types.Class
@@ -21,18 +17,14 @@ module Data.Aeson.Types.Class
21 -- ** Core JSON classes
17 -- ** Core JSON classes
22 FromJSON(..)
18 FromJSON(..)
23 , ToJSON(..)
19 , ToJSON(..)
24−#ifdef GENERICS
25 -- ** Generic JSON classes
20 -- ** Generic JSON classes
26 , GFromJSON(..)
21 , GFromJSON(..)
27 , GToJSON(..)
22 , GToJSON(..)
28 , genericToJSON
23 , genericToJSON
29 , genericParseJSON
24 , genericParseJSON
30−#endif
31 ) where
25 ) where
32
26
33import Data.Aeson.Types.Internal
27import Data.Aeson.Types.Internal
34−
35−#ifdef GENERICS
36import GHC.Generics
28import GHC.Generics
37
29
38-- | Class of generic representation types ('Rep') that can be converted to JSON.
30-- | Class of generic representation types ('Rep') that can be converted to JSON.
@@ -58,7 +50,6 @@ genericToJSON opts = gToJSON opts . from
58-- type is an instance of 'Generic'.
50-- type is an instance of 'Generic'.
59genericParseJSON :: (Generic a, GFromJSON (Rep a)) => Options -> Value -> Parser a
51genericParseJSON :: (Generic a, GFromJSON (Rep a)) => Options -> Value -> Parser a
60genericParseJSON opts = fmap to . gParseJSON opts
52genericParseJSON opts = fmap to . gParseJSON opts
61−#endif
62
53
63-- | A type that can be converted to JSON.
54-- | A type that can be converted to JSON.
64--
55--
@@ -115,10 +106,8 @@ genericParseJSON opts = fmap to . gParseJSON opts
115class ToJSON a where
106class ToJSON a where
116 toJSON :: a -> Value
107 toJSON :: a -> Value
117
108
118−#ifdef GENERICS
119 default toJSON :: (Generic a, GToJSON (Rep a)) => a -> Value
109 default toJSON :: (Generic a, GToJSON (Rep a)) => a -> Value
120 toJSON = genericToJSON defaultOptions
110 toJSON = genericToJSON defaultOptions
121−#endif
122
111
123-- | A type that can be converted from JSON, with the possibility of
112-- | A type that can be converted from JSON, with the possibility of
124-- failure.
113-- failure.
@@ -188,7 +177,5 @@ class ToJSON a where
188class FromJSON a where
177class FromJSON a where
189 parseJSON :: Value -> Parser a
178 parseJSON :: Value -> Parser a
190
179
191−#ifdef GENERICS
192 default parseJSON :: (Generic a, GFromJSON (Rep a)) => Value -> Parser a
180 default parseJSON :: (Generic a, GFromJSON (Rep a)) => Value -> Parser a
193 parseJSON = genericParseJSON defaultOptions
181 parseJSON = genericParseJSON defaultOptions
194−#endif
Data/Aeson/Types/Instances.hs+2−6
@@ -1,11 +1,8 @@
1{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
1{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts, FlexibleInstances,
2 GeneralizedNewtypeDeriving, IncoherentInstances, OverlappingInstances,
2 GeneralizedNewtypeDeriving, IncoherentInstances, OverlappingInstances,
3 OverloadedStrings, UndecidableInstances, ViewPatterns #-}
3 OverloadedStrings, UndecidableInstances, ViewPatterns #-}
4−{-# OPTIONS_GHC -fno-warn-orphans #-}
5−
6−#ifdef GENERICS
7{-# LANGUAGE DefaultSignatures #-}
4{-# LANGUAGE DefaultSignatures #-}
8−#endif
5+{-# OPTIONS_GHC -fno-warn-orphans #-}
9
6
10-- TODO: Drop this when we remove support for Data.Attoparsec.Number
7-- TODO: Drop this when we remove support for Data.Attoparsec.Number
11#if MIN_VERSION_attoparsec(0,12,0)
8#if MIN_VERSION_attoparsec(0,12,0)
@@ -29,13 +26,12 @@ module Data.Aeson.Types.Instances
29 -- ** Core JSON classes
26 -- ** Core JSON classes
30 FromJSON(..)
27 FromJSON(..)
31 , ToJSON(..)
28 , ToJSON(..)
32−#ifdef GENERICS
33 -- ** Generic JSON classes
29 -- ** Generic JSON classes
34 , GFromJSON(..)
30 , GFromJSON(..)
35 , GToJSON(..)
31 , GToJSON(..)
36 , genericToJSON
32 , genericToJSON
37 , genericParseJSON
33 , genericParseJSON
38−#endif
34+
39 -- * Types
35 -- * Types
40 , DotNetTime(..)
36 , DotNetTime(..)
41
37
aeson.cabal−1
@@ -126,7 +126,6 @@ library
126 ghc-prof-options: -auto-all
126 ghc-prof-options: -auto-all
127
127
128 ghc-options: -O2 -Wall
128 ghc-options: -O2 -Wall
129− cpp-options: -DGENERICS
130
129
131test-suite tests
130test-suite tests
132 type: exitcode-stdio-1.0
131 type: exitcode-stdio-1.0