Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions that make up the internal structure of the encoders.
Synopsis
- data EncoderFns i f a = EncoderFns {
- finaliseEncoding :: i -> Json
- initialEncoding :: a -> f i
- type Encoder f a = EncoderFns Json f a
- type Encoder' a = EncoderFns Json Identity a
- type ObjEncoder f a = EncoderFns (JObject WS Json) f a
- type ObjEncoder' a = EncoderFns (JObject WS Json) Identity a
- runEncoder :: Functor f => EncoderFns i f a -> a -> f Json
- runPureEncoder :: EncoderFns i Identity a -> a -> Json
- jsonEncoder :: (a -> f Json) -> EncoderFns Json f a
- objEncoder :: (a -> f (JObject WS Json)) -> EncoderFns (JObject WS Json) f a
- generaliseEncoder :: Monad f => EncoderFns i Identity a -> EncoderFns i f a
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.
EncoderFns | |
|
Instances
MFunctor (EncoderFns i :: (Type -> Type) -> Type -> Type) Source # | |
Defined in Waargonaut.Encode.Types hoist :: Monad m => (forall a. m a -> n a) -> EncoderFns i m b -> EncoderFns i n b # | |
Contravariant (EncoderFns o f) Source # | |
Defined in Waargonaut.Encode.Types contramap :: (a -> b) -> EncoderFns o f b -> EncoderFns o f a # (>$) :: b -> EncoderFns o f b -> EncoderFns o f a # | |
Applicative f => Divisible (EncoderFns (JObject WS Json) f) Source # | |
Defined in Waargonaut.Encode.Types divide :: (a -> (b, c)) -> EncoderFns (JObject WS Json) f b -> EncoderFns (JObject WS Json) f c -> EncoderFns (JObject WS Json) f a # | |
Applicative f => Decidable (EncoderFns (JObject WS Json) f) Source # | |
Defined in Waargonaut.Encode.Types |
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 #
runPureEncoder :: EncoderFns i Identity a -> a -> Json Source #
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'