composite-aeson-0.3.0.0: JSON for Vinyl/Frames records

Composite.Aeson.Base

Synopsis

# Documentation

newtype ToJson a Source #

Type of functions which take a value a and convert it to an Value.

Wrapper around a function of type a -> Aeson.Value.

Doesn't currently include support for the newer Aeson Encoding machinery, but should.

Constructors

 ToJson FieldsunToJson :: a -> Value

Instances

 Source # Methodscontramap :: (a -> b) -> ToJson b -> ToJson a #(>$) :: b -> ToJson b -> ToJson a # Wrapped (ToJson a0) Source # Associated Typestype Unwrapped (ToJson a0) :: * # Methods_Wrapped' :: Iso' (ToJson a0) (Unwrapped (ToJson a0)) # (~) * (ToJson a0) t0 => Rewrapped (ToJson a1) t0 Source # type Unwrapped (ToJson a0) Source # type Unwrapped (ToJson a0) = a0 -> Value newtype FromJson e a Source # Type of parsers which might emit some custom error of type e and produce a value of type a on success. a is the type of value that can be parsed from JSON using this profunctor, and e is the type of custom error that can be produced when the JSON is unacceptable. If your parser doesn't produce any custom errors, leave this type polymorphic. Wrapper about an aeson-better-errors Parse e a. Constructors  FromJson FieldsunFromJson :: Parse e a Instances  Source # Methodsfmap :: (a -> b) -> FromJson e a -> FromJson e b #(<$) :: a -> FromJson e b -> FromJson e a # Wrapped (FromJson e0 a0) Source # Associated Typestype Unwrapped (FromJson e0 a0) :: * # Methods_Wrapped' :: Iso' (FromJson e0 a0) (Unwrapped (FromJson e0 a0)) # (~) * (FromJson e0 a0) t0 => Rewrapped (FromJson e1 a1) t0 Source # type Unwrapped (FromJson e0 a0) Source # type Unwrapped (FromJson e0 a0) = Parse e0 a0

data JsonProfunctor e a b Source #

Type of profunctors which produce and consume JSON, a composition of ToJson and FromJson.

a is the type of value that can be converted to Value using this profunctor. b is the type of value that can be parsed from JSON using this profunctor, and e is the type of custom error that can be produced when the JSON is unacceptable. If your parser doesn't produce any custom errors, leave this type polymorphic.

Profunctors must have two type parameters a and b so this type has two, but JsonProfunctors with different types aren't useful for JSON processing directly. See JsonFormat for a wrapper which fixes the two types.

Doesn't currently include support for the newer Aeson Encoding machinery, but should.

Constructors

 JsonProfunctor (a -> Value) (Parse e b)

Instances

 Source # Methodsdimap :: (a -> b) -> (c -> d) -> JsonProfunctor e b c -> JsonProfunctor e a d #lmap :: (a -> b) -> JsonProfunctor e b c -> JsonProfunctor e a c #rmap :: (b -> c) -> JsonProfunctor e a b -> JsonProfunctor e a c #(#.) :: Coercible * c b => (b -> c) -> JsonProfunctor e a b -> JsonProfunctor e a c #(.#) :: Coercible * b a => JsonProfunctor e b c -> (a -> b) -> JsonProfunctor e a c #

_JsonProfunctor :: Iso (JsonProfunctor e a b) (JsonProfunctor e' a' b') (ToJson a, FromJson e b) (ToJson a', FromJson e' b') Source #

Observe that a JsonProfunctor is isomorphic to a pair with a ToJson and FromJson.

newtype JsonFormat e a Source #

Wrapper around JsonProfunctor for use in JSON processing when the profunctor represents a bijection between JSON and a single type a, i.e. for JsonProfunctor e a a.

Constructors

 JsonFormat FieldsunJsonFormat :: JsonProfunctor e a a

Instances

 Wrapped (JsonFormat e0 a0) Source # Associated Typestype Unwrapped (JsonFormat e0 a0) :: * # Methods_Wrapped' :: Iso' (JsonFormat e0 a0) (Unwrapped (JsonFormat e0 a0)) # (~) * (JsonFormat e0 a0) t0 => Rewrapped (JsonFormat e1 a1) t0 Source # type Unwrapped (JsonFormat e0 a0) Source # type Unwrapped (JsonFormat e0 a0) = JsonProfunctor e0 a0 a0

toJsonWithFormat :: JsonFormat e a -> a -> Value Source #

Given a JsonFormat for a, convert a value of a into an Value.

fromJsonWithFormat :: JsonFormat e a -> Parse e a Source #

Given a JsonFormat for a which can produce custom errors of type e, yield an aeson-better-errors Parse which can be used to consume JSON.

parseJsonWithFormat :: (e -> Text) -> JsonFormat e a -> Value -> Parser a Source #

Given a JsonFormat for a which produces custom errors of type e and some function to format those errors as messages, produce an Aeson parser function Value -> Parser a.

Given a JsonFormat for a which doesn't produce custom errors, produce an Aeson parser function Value -> Parser a.

dimapJsonFormat :: (b -> a) -> (a -> b) -> JsonFormat e a -> JsonFormat e b Source #

Wrap a JsonFormat for type a in a pair of functions representing an isomorphism between a and b to produce a new JsonFormat for b.

jsonFormatWithIso :: AnIso' b a -> JsonFormat e a -> JsonFormat e b Source #

Wrap a JsonFormat for type a in an isomorphism to produce a new JsonFormat for b.

wrappedJsonFormat :: Wrapped a => JsonFormat e (Unwrapped a) -> JsonFormat e a Source #

Given a format for the value type inside some wrapper type a which instances Wrapped, produce a format which works on the wrapper type.