Various functions for declaring new instances of Binary for types.

- mapWrite :: HasBinary b m => (a -> b) -> WriteBinary m -> a -> m ()
- mapRead :: (Monad m, HasBinary b m) => (b -> a) -> ReadBinary m -> m a
- mapWriteIO :: (HasBinary b m, MonadIO m) => (a -> IO b) -> WriteBinary m -> a -> m ()
- mapReadIO :: (HasBinary b m, MonadIO m) => (b -> IO a) -> ReadBinary m -> m a
- data ArgMonad arg m a
- mkArgMonad :: (arg -> m a) -> ArgMonad arg m a
- toArgMonad :: m a -> ArgMonad arg m a
- runArgMonad :: arg -> ArgMonad arg m a -> m a
- writeBinaryToArgMonad :: WriteBinary m -> WriteBinary (ArgMonad arg m)
- readBinaryToArgMonad :: ReadBinary m -> ReadBinary (ArgMonad arg m)
- data WrappedBinary = forall v . HasBinary v IO => WrappedBinary v
- hWriteWrappedBinary :: Handle -> WrappedBinary -> IO ()
- data WrapBinary m = forall v . HasBinary v m => WrapBinary v

# Documentation

mapWrite :: HasBinary b m => (a -> b) -> WriteBinary m -> a -> m ()Source

mapRead :: (Monad m, HasBinary b m) => (b -> a) -> ReadBinary m -> m aSource

mapWriteIO :: (HasBinary b m, MonadIO m) => (a -> IO b) -> WriteBinary m -> a -> m ()Source

A monad which hides an additional value which the `HasBinary`

instances should be able to get at. This is used, for example,
by CodedValue, to make the `View`

available to instances.

mkArgMonad :: (arg -> m a) -> ArgMonad arg m aSource

toArgMonad :: m a -> ArgMonad arg m aSource

runArgMonad :: arg -> ArgMonad arg m a -> m aSource

writeBinaryToArgMonad :: WriteBinary m -> WriteBinary (ArgMonad arg m)Source

readBinaryToArgMonad :: ReadBinary m -> ReadBinary (ArgMonad arg m)Source

data WrappedBinary Source

A wrapper for instances of Binary. This can be written, but not read (since we wouldn't know what type to decode).

forall v . HasBinary v IO => WrappedBinary v |

hWriteWrappedBinary :: Handle -> WrappedBinary -> IO ()Source

Write a `WrappedBinary`