Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class Monad m => SafeBufferMonad s m | m -> s where
- newtype SafeBufferT s m a = SafeBufferT {
- runBufferT :: ReaderT (IORef s) m a
- runBuffer :: forall s m a b. (MonadIO m, MonadMask m, Monoid s) => (s -> m b) -> SafeBufferT s m a -> m a
- tryRunBuffer :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferT s m a -> m (s, Either e a)
- execBuffer :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferT s m a -> m s
- newtype SafeBufferConcurrentT s m a = SafeBufferConcurrentT {
- runBufferConcurrentT :: ReaderT (TVar s) m a
- runBufferConcurrently :: forall s m a b. (MonadIO m, MonadMask m, Monoid s) => (s -> m b) -> SafeBufferConcurrentT s m a -> m a
- tryRunBufferConcurrently :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferConcurrentT s m a -> m (s, Either e a)
- execBufferConcurrently :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferConcurrentT s m a -> m s
SafeBufferMonad
class Monad m => SafeBufferMonad s m | m -> s where Source #
readBuffer :: m s Source #
Retrieves the buffer's current content.
writeBuffer :: s -> m () Source #
Appends a message to the buffer.
clearBuffer :: m s Source #
Retrieves the buffer's current content before clearing it.
modifyBuffer :: (s -> s) -> m () Source #
Applies a given function to the buffer's content.
(MonadIO m, Monoid s) => SafeBufferMonad s (SafeBufferConcurrentT s m) Source # | |
(MonadIO m, Monoid s) => SafeBufferMonad s (SafeBufferT s m) Source # | |
SafeBufferT
newtype SafeBufferT s m a Source #
SafeBufferT | |
|
runBuffer :: forall s m a b. (MonadIO m, MonadMask m, Monoid s) => (s -> m b) -> SafeBufferT s m a -> m a Source #
Runs a buffer and applies a given function to it. If any exception occurs while running the buffer, the function still runs before the exception is rethrown.
tryRunBuffer :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferT s m a -> m (s, Either e a) Source #
Runs a buffer and returns it, along with either an exception or the computation's result.
It purposefully does NOT catch async exceptions. To understand why, see Asynchronous exception handling in Haskell.
execBuffer :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferT s m a -> m s Source #
Runs a buffer and swallow exceptions of type e
.
It purposefully does NOT catch async exceptions. To understand why, see Asynchronous exception handling in Haskell.
SafeBufferConcurrentT
newtype SafeBufferConcurrentT s m a Source #
SafeBufferConcurrentT | |
|
runBufferConcurrently :: forall s m a b. (MonadIO m, MonadMask m, Monoid s) => (s -> m b) -> SafeBufferConcurrentT s m a -> m a Source #
Runs a buffer that can be safely shared accross threads and applies a given function to it. If an exception occurs while running the buffer, the function still runs before the exception is rethrown.
tryRunBufferConcurrently :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferConcurrentT s m a -> m (s, Either e a) Source #
Runs a buffer that can be safely shared accross threads and returns it, along with either an exception or the computation's result.
It purposefully does NOT catch async exceptions. To understand why, see Asynchronous exception handling in Haskell.
execBufferConcurrently :: forall e s m a. (MonadIO m, MonadCatch m, Monoid s, Exception e) => SafeBufferConcurrentT s m a -> m s Source #
Runs a buffer that can be safely shared accross threads, and swallows exceptions of type e
.
It purposefully does NOT catch async exceptions. To understand why, see Asynchronous exception handling in Haskell.