Closed
Description
While playing with #341 I really missed these classes, as in http://hackage.haskell.org/package/transformers-0.5.1.0/docs/Data-Functor-Classes.html
class FromJSON1 f where
liftParseJSON :: (Value -> Parser a) -> Value -> Parser (f a)
parseJSON1 :: (FromJSON1 f, FromJSON 1) -> Value -> Parser (f a)
parseJSON1 = liftParseJSON parseJSON
class ToJSON1 f where
liftToJSON :: (a -> Value) -> f a -> Value
liftToEncoding :: (a -> Encoding) -> f a -> Encoding
-- Unfortunately there cannot be default implementation using 'liftToJSON'
toJSON1 :: (ToJSON1 f, ToJSON a) -> f a -> Value
toJSON1 = liftToJSON toJSON
toEncoding1 :: (ToJSON1 f, ToJSON a) -> f a -> Encoding
toEncoding1 = liftToEncoding toEncoding
Actually ToJSON2
and FromJSON2
would be useful too, their instance for tuple and Either
.
Those could live in separate package, but then as they are more general (parseJSON1
is not FromJSON1
method), it would mean reimplementing many instances (and internals).