-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Use other Monads in functions that asks for an IO Monad.
--
-- This module provides utilities to use functions that are not in the IO
-- Monad as a callback in functions that expects an IO Monad.
@package interleavableIO
@version 0.0.1
-- | This module provides utilities to use functions that are not in the
-- IO Monad as a callback in functions that expects an
-- IO Monad.
module Control.Monad.Trans.InterleavableIO
-- | 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.
class (MonadIO inner) => InterleavableIO inner trans buffer | trans -> inner buffer
embed :: (InterleavableIO inner trans buffer) => (buffer -> inner result) -> trans result
callback :: (InterleavableIO inner trans buffer) => buffer -> trans result -> inner result
-- | 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.
embedCallback :: (InterleavableIO innerCaller caller buffer, InterleavableIO innerFunction function buffer) => (innerFunction resultFunction -> innerCaller resultCaller) -> function resultFunction -> caller resultCaller
-- | This is a utilitary function to construct new instances of
-- InterleavableIO, in Monads that contain
-- InterleavableIO Monads. It simply calls embed with an
-- inner buffer that will be used by the inner instance of
-- InterleavableIO.
embedInner :: (InterleavableIO inner trans innerBuffer) => ((buffer, innerBuffer) -> inner result) -> buffer -> trans result
-- | Function useful to convert a pure State monad in a
-- StateT IO, to be used with the instance of
-- InterleavableIO StateT.
promoteState :: (MonadState state monad) => State state result -> monad result
-- | Function useful to convert a pure Reader monad in a
-- ReaderT IO, to be used with the instance of
-- InterleavableIO ReaderT.
promoteReader :: (MonadReader reader monad) => Reader reader result -> monad result
-- | Function useful to convert a pure Writer monad in a
-- WriterT IO, to be used with the instance of
-- InterleavableIO WriterT.
promoteWriter :: (MonadWriter writer monad) => Writer writer result -> monad result
-- | Error data type used in ErrorT instance.
data InterleaveErrorTException error
InterleaveErrorTException :: error -> InterleaveErrorTException error
instance Typeable1 InterleaveErrorTException
instance (MonadIO inner, InterleavableIO deepInner inner buffer, InterleavableIO IO inner buffer, InterleavableIO IO deepInner buffer, Error error, Typeable error) => InterleavableIO deepInner (ErrorT error inner) ((), buffer)
instance (MonadIO inner, InterleavableIO deepInner inner buffer, Monoid writer) => InterleavableIO deepInner (WriterT writer inner) (IORef writer, buffer)
instance (MonadIO inner, InterleavableIO deepInner inner buffer) => InterleavableIO deepInner (ReaderT reader inner) (reader, buffer)
instance (MonadIO inner, InterleavableIO deepInner inner buffer) => InterleavableIO deepInner (StateT state inner) (IORef state, buffer)
instance InterleavableIO IO IO ()