@@ -1,8 +1,4 @@
1−{-# LANGUAGE CPP, FlexibleContexts #-}
1+{-# LANGUAGE DefaultSignatures, FlexibleContexts #-}
4−{-# LANGUAGE DefaultSignatures #-}
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(..)
25 -- ** Generic JSON classes
20 -- ** Generic JSON classes
26 , GFromJSON(..)
21 , GFromJSON(..)
27 , GToJSON(..)
22 , GToJSON(..)
28 , genericToJSON
23 , genericToJSON
29 , genericParseJSON
24 , genericParseJSON
33import Data.Aeson.Types.Internal
27import Data.Aeson.Types.Internal
36import GHC.Generics
28import GHC.Generics
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
63-- | A type that can be converted to JSON.
54-- | A type that can be converted to JSON.
@@ -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
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
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
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