uni-util-2.2.1.2: Utilities for the uniform workbench

Safe HaskellSafe-Infered

Util.BinaryUtils

Description

Various functions for declaring new instances of Binary for types.

Synopsis

Documentation

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

Given a function which converts an (a) to something we can already convert to binary, return a writeBin function to be used in instances of HasBinary (a).

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

Given a function which converts something we can already read from binary to (a), return a readBin function to be used in instances of HasBinary (a).

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

Like mapWrite, but the conversion function is also allowed to use IO.

mapReadIO :: (HasBinary b m, MonadIO m) => (b -> IO a) -> ReadBinary m -> m aSource

LIke mapRead, but the conversion function is also allowed to use IO.

data ArgMonad arg m a 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.

Instances

Monad m => Monad (ArgMonad arg m) 
Functor m => Functor (ArgMonad arg m) 
MonadIO m => MonadIO (ArgMonad arg m) 

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

toArgMonad :: m a -> ArgMonad arg m aSource

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

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).

Constructors

forall v . HasBinary v IO => WrappedBinary v 

data WrapBinary m Source

Constructors

forall v . HasBinary v m => WrapBinary v 

Instances