Portability | unportable |
---|---|
Stability | unstable |
Maintainer | Marco Tlio Gontijo e Silva <marcot@riseup.net> |
- class MonadIO inner => InterleavableIO inner trans buffer | trans -> inner buffer where
- embedCallback :: (InterleavableIO innerCaller caller buffer, InterleavableIO innerFunction function buffer) => (innerFunction resultFunction -> innerCaller resultCaller) -> function resultFunction -> caller resultCaller
- embedInner :: InterleavableIO inner trans innerBuffer => ((buffer, innerBuffer) -> inner result) -> buffer -> trans result
- promoteState :: MonadState state monad => State state result -> monad result
- promoteReader :: MonadReader reader monad => Reader reader result -> monad result
- promoteWriter :: MonadWriter writer monad => Writer writer result -> monad result
- data InterleaveErrorTException error = InterleaveErrorTException error
Documentation
class MonadIO inner => InterleavableIO inner trans buffer | trans -> inner buffer whereSource
MonadIO
types that instanciate this class can interleave an IO
function, and be used as a callback in a function that asks for an IO
monad.
InterleavableIO IO IO () | |
(MonadIO inner, InterleavableIO deepInner inner buffer, InterleavableIO IO inner buffer, InterleavableIO IO deepInner buffer, Error error, Typeable error) => InterleavableIO deepInner (ErrorT error inner) ((), buffer) | |
(MonadIO inner, InterleavableIO deepInner inner buffer, Monoid writer) => InterleavableIO deepInner (WriterT writer inner) (IORef writer, buffer) | |
(MonadIO inner, InterleavableIO deepInner inner buffer) => InterleavableIO deepInner (ReaderT reader inner) (reader, buffer) | |
(MonadIO inner, InterleavableIO deepInner inner buffer) => InterleavableIO deepInner (StateT state inner) (IORef state, buffer) |
:: (InterleavableIO innerCaller caller buffer, InterleavableIO innerFunction function buffer) | |
=> (innerFunction resultFunction -> innerCaller resultCaller) | caller |
-> function resultFunction | callback |
-> caller resultCaller |
This is an utilitary function to the most simple use-case of this module.
It makes it possible to use the function caller
, that needs an IO
as input, with any Monad
that instanciates InterleavableIO
.
:: InterleavableIO inner trans innerBuffer | |
=> ((buffer, innerBuffer) -> inner result) |
|
-> buffer |
|
-> trans result |
This is a utilitary function to construct new instances of
InterleavableIO
, in Monad
s that contain InterleavableIO
Monad
s. It
simply calls embed with an inner buffer that will be used by the inner
instance of InterleavableIO
.
promoteState :: MonadState state monad => State state result -> monad resultSource
Function useful to convert a pure State
monad in a StateT
IO
, to be
used with the instance of InterleavableIO
StateT
.
promoteReader :: MonadReader reader monad => Reader reader result -> monad resultSource
Function useful to convert a pure Reader
monad in a ReaderT
IO
, to be
used with the instance of InterleavableIO
ReaderT
.
promoteWriter :: MonadWriter writer monad => Writer writer result -> monad resultSource
Function useful to convert a pure Writer
monad in a WriterT
IO
, to be
used with the instance of InterleavableIO
WriterT
.
data InterleaveErrorTException error Source
Error data type used in ErrorT
instance.