Commits

basvandijk committed 27b5db0

Add documentation about parameterizing the generic encoding

  • Participants
  • Parent commits 424169f

Comments (0)

Files changed (1)

File Data/Aeson/Types/Class.hs

 --
 -- instance ToJSON Coord
 -- @
+--
+-- Note that, instead of using @DefaultSignatures@, it's also possible
+-- to parameterize the generic encoding by using 'gToJSON' applied to
+-- the encoding 'Options':
+--
+-- @
+-- instance ToJSON Coord where
+--     toJSON = 'gToJSON' 'defaultOptions' . from
+-- @
 class ToJSON a where
     toJSON   :: a -> Value
 
 --
 -- instance FromJSON Coord
 -- @
+--
+-- Note that, instead of using @DefaultSignatures@, it's also possible
+-- to parameterize the generic decoding by using 'gParseJSON' applied
+-- to the encoding 'Options':
+--
+-- @
+-- instance FromJSON Coord where
+--     parseJSON = fmap to . 'gParseJSON' 'defaultOptions'
+-- @
+
 class FromJSON a where
     parseJSON :: Value -> Parser a