instance (ToJSON a, ToJSON b) => ToJSON (Either a b) where

- toJSON (Left a) = toJSON a

- toJSON (Right b) = toJSON b

+ toJSON (Left a) = Array (V.fromList [String "Left", toJSON a])

+ toJSON (Right b) = Array (V.fromList [String "Right", toJSON b])

instance (FromJSON a, FromJSON b) => FromJSON (Either a b) where

- parseJSON a = Left <$> parseJSON a <|> Right <$> parseJSON a

+ parseJSON v@(Array vec) =

+ then typeMismatch "Either a b" v

+ "Left" -> Left <$> parseJSON (vec V.! 1)

+ "Right" -> Right <$> parseJSON (vec V.! 1)

+ _ -> typeMismatch "Either a b" v

+ parseJSON v = typeMismatch "Either a b" v

instance ToJSON Bool where