Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Descriptor s a = Descriptor (Get a, s -> Put)
- unwrapGet :: Descriptor s a -> Get a
- unwrapPut :: s -> Descriptor s a -> PutM ()
- serialize :: s -> Descriptor s a -> ByteString
- deserialize :: ByteString -> Descriptor s s -> Either String s
Documentation
newtype Descriptor s a Source #
Descriptor s a
is an applicative functor that describes the binary structure for a structure s
while deserializing value a
.
Descriptor (Get a, s -> Put) |
Instances
Monad (Descriptor s) Source # | |
Defined in Data.Serialize.Descriptor (>>=) :: Descriptor s a -> (a -> Descriptor s b) -> Descriptor s b # (>>) :: Descriptor s a -> Descriptor s b -> Descriptor s b # return :: a -> Descriptor s a # fail :: String -> Descriptor s a # | |
Functor (Descriptor s) Source # | |
Defined in Data.Serialize.Descriptor fmap :: (a -> b) -> Descriptor s a -> Descriptor s b # (<$) :: a -> Descriptor s b -> Descriptor s a # | |
Applicative (Descriptor s) Source # | |
Defined in Data.Serialize.Descriptor pure :: a -> Descriptor s a # (<*>) :: Descriptor s (a -> b) -> Descriptor s a -> Descriptor s b # liftA2 :: (a -> b -> c) -> Descriptor s a -> Descriptor s b -> Descriptor s c # (*>) :: Descriptor s a -> Descriptor s b -> Descriptor s b # (<*) :: Descriptor s a -> Descriptor s b -> Descriptor s a # |
unwrapGet :: Descriptor s a -> Get a Source #
unwrapGet desc
takes a Descriptor
and returns only the internal Get
monad.
unwrapPut :: s -> Descriptor s a -> PutM () Source #
unwrapPut s desc
takes the structure being described and a Descriptor
for it, and returns the internal Put
monad.
serialize :: s -> Descriptor s a -> ByteString Source #
Convenience function for runPut . unwrapPut s
deserialize :: ByteString -> Descriptor s s -> Either String s Source #
Convenience function for flip runGet bs . unwrapGet