waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Encode.Types

Description

Types and functions that make up the internal structure of the encoders.

Synopsis

Types

data EncoderFns i f a Source #

Define an "encoder" as a function from some a to some Json with the allowance for some context f.

The helper functions jsonEncoder and objEncoder are probably what you want to use.

Constructors

EncoderFns 

Fields

Instances

Instances details
MFunctor (EncoderFns i :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Waargonaut.Encode.Types

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> EncoderFns i m b -> EncoderFns i n b

Contravariant (EncoderFns o f) Source # 
Instance details

Defined in Waargonaut.Encode.Types

Methods

contramap :: (a -> b) -> EncoderFns o f b -> EncoderFns o f a #

(>$) :: b -> EncoderFns o f b -> EncoderFns o f a #

Applicative f => Decidable (EncoderFns (JObject WS Json) f) Source # 
Instance details

Defined in Waargonaut.Encode.Types

Methods

lose :: (a -> Void) -> EncoderFns (JObject WS Json) f a

choose :: (a -> Either b c) -> EncoderFns (JObject WS Json) f b -> EncoderFns (JObject WS Json) f c -> EncoderFns (JObject WS Json) f a

Applicative f => Divisible (EncoderFns (JObject WS Json) f) Source # 
Instance details

Defined in Waargonaut.Encode.Types

Methods

divide :: (a -> (b, c)) -> EncoderFns (JObject WS Json) f b -> EncoderFns (JObject WS Json) f c -> EncoderFns (JObject WS Json) f a

conquer :: EncoderFns (JObject WS Json) f a

Useful aliases

type Encoder f a = EncoderFns Json f a Source #

As a convenience, this type defines the i to be a specific Json structure:

type Encoder' a = EncoderFns Json Identity a Source #

As a convenience, this type is a pure Encoder over Identity in place of the f.

type ObjEncoder f a = EncoderFns (JObject WS Json) f a Source #

As a convenience, this type defines the i to be a specific 'JObject WS Json' structure:

type ObjEncoder' a = EncoderFns (JObject WS Json) Identity a Source #

As a convenience, this type is a pure ObjEncoder over Identity in place of the f.

Runners

runEncoder :: Functor f => EncoderFns i f a -> a -> f Json Source #

Run any encoder to the Json representation, allowing for some Functor context f.

runPureEncoder :: EncoderFns i Identity a -> a -> Json Source #

Run any encoder to the Json representation, with the context specialised to Identity for convenience.

Helpers

jsonEncoder :: (a -> f Json) -> EncoderFns Json f a Source #

Helper function for creating an Encoder, provides the default finaliseEncoding function for Json encoders.

objEncoder :: (a -> f (JObject WS Json)) -> EncoderFns (JObject WS Json) f a Source #

Helper function for creating a JSON object Encoder. Provides the default finaliseEncoding function for completing the JObject to the necessary Json type.

generaliseEncoder :: Monad f => EncoderFns i Identity a -> EncoderFns i f a Source #

Generalise any Encoder a' to 'Encoder f a'