Serializer ties Get and PutM monads
into a single datatype and allows
transforming the monads with a monad transformer
for e.g. adding ExceptT or ReaderT layers.
Modulehnix-store-remote-0.7.0.0Haskell2010
Data.Serializer
Serializer ties Get and PutM monads
into a single datatype and allows
transforming both monads with a monad transformer
for adding extra layers like ExceptT
(for example when putS can fail due to unsupported
version of a protocol) or ReaderT (when we need
to serialize a data type based differently based
on a protocol version).
- 5 types
- 11 values
- Packagehnix-store-remote-0.7.0.0
- Exports16
- LanguageHaskell2010
- LicenceApache-2.0
- SourceSerializer.hs
Serializer
1 declarationRunners
runGetS :: (Monad (t Get), MonadTrans t)=> Serializer t aSerializer
-> (t Get a -> Get b)Tranformer runner
-> ByteStringByteString to parse
-> Either String b
Runner for getS of Serializer
runPutS :: (Monad (t PutM), MonadTrans t)=> Serializer t aSerializer
-> (t PutM () -> PutM b)Tranformer runner
-> aValue to (out)put
-> (b, ByteString)
Runner for putS of Serializer
Simple serializer
1 declarationSimple Serializer
Simple runners
Runner for getS of SimpleSerializer
Runner for putS of SimpleSerializer
From Get/Put, Serialize
2 declarationsLift Get a and Putter a into Serializer
Lift Serialize a instance into Serializer
Combinators
3 declarationsmapIsoSerializer :: Functor (t Get)=> (a -> b)Map over
getS-> (b -> a)Map over
putS-> Serializer t a-> Serializer t b
Map over Serializer
mapPrismSerializer :: MonadError eGet (t Get)=> (a -> Either eGet b)Map over
getS-> (b -> a)Map over
putS-> Serializer t a-> Serializer t b
Map over Serializer where getS
can return Either
Tuple combinator
Utility
3 declarationsWrapper for both GetS errors
the one that occurs when
failis calledcustom one when
ExceptTis used
Constructors
SerializerError_GetFail StringSerializerError_Get customGetError
Instances3Eq, Ord, Show
Eq customGetError => Eq (GetSerializerError customGetError)Defined in hnix-store-remote-0.7.0.0 · Data.SerializerOrd customGetError => Ord (GetSerializerError customGetError)Defined in hnix-store-remote-0.7.0.0 · Data.SerializerShow customGetError => Show (GetSerializerError customGetError)Defined in hnix-store-remote-0.7.0.0 · Data.Serializer
Helper for transforming nested Eithers
into GetSerializerError wrapper
Helper for transforming runPutM result
Re-exports
2 declarationsThe Get monad is an Exception and State monad.
Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
Monad GetDefined in cereal-0.5.8.3 · Data.Serialize.GetFunctor GetDefined in cereal-0.5.8.3 · Data.Serialize.GetMonadFail GetDefined in cereal-0.5.8.3 · Data.Serialize.GetApplicative GetDefined in cereal-0.5.8.3 · Data.Serialize.GetAlternative GetDefined in cereal-0.5.8.3 · Data.Serialize.GetMonadPlus GetDefined in cereal-0.5.8.3 · Data.Serialize.Get
The PutM type. A Writer monad over the efficient Builder monoid.
Instances5Monad, Functor, Applicative, Semigroup, Monoid
Monad PutMDefined in cereal-0.5.8.3 · Data.Serialize.PutFunctor PutMDefined in cereal-0.5.8.3 · Data.Serialize.PutApplicative PutMDefined in cereal-0.5.8.3 · Data.Serialize.PutSemigroup (PutM ())Defined in cereal-0.5.8.3 · Data.Serialize.PutMonoid (PutM ())Defined in cereal-0.5.8.3 · Data.Serialize.Put