Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Writer tag w = WriterT tag w Identity
- writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a
- runWriter :: proxy tag -> Writer tag w a -> (a, w)
- execWriter :: proxy tag -> Writer tag w a -> w
- data WriterT tag w m a
- writerT :: proxy tag -> m (a, w) -> WriterT tag w m a
- runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w)
- execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w
- mapWriterT :: proxy tag -> (m (a, w) -> n (b, w')) -> WriterT tag w m a -> WriterT tag w' n b
- tell :: Monad m => proxy tag -> w -> WriterT tag w m ()
- listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w)
- pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
- liftCallCC :: Monoid w => proxy tag -> CallCC m (a, w) (b, w) -> CallCC (WriterT tag w m) a b
- liftCatch :: proxy tag -> Catch e m (a, w) -> Catch e (WriterT tag w m) a
- liftListen :: Monad m => proxy tag -> Listen w' m (a, w) -> Listen w' (WriterT tag w m) a
- liftPass :: Monad m => proxy tag -> Pass w' m (a, w) -> Pass w' (WriterT tag w m) a
The Writer monad
writer :: Monad m => proxy tag -> (a, w) -> WriterT tag w m a Source
Constructor for computations in the writer monad
(the inverse of runWriter
).
runWriter :: proxy tag -> Writer tag w a -> (a, w) Source
Runs a Writer
and returns both the normal value
and the final accumulator.
execWriter :: proxy tag -> Writer tag w a -> w Source
Runs a Writer
and returns the final accumulator,
discarding the normal value.
The WriterT monad transformer
The writer monad transformer.
The return
function produces the output mempty
, while >>=
combines
the outputs of the subcomputations using mappend
.
writerT :: proxy tag -> m (a, w) -> WriterT tag w m a Source
Constructor for computations in the writer monad transformer.
runWriterT :: proxy tag -> WriterT tag w m a -> m (a, w) Source
Runs a WriterT
and returns both the normal value
and the final accumulator.
execWriterT :: Monad m => proxy tag -> WriterT tag w m a -> m w Source
Runs a WriterT
and returns the final accumulator,
discarding the normal value.
mapWriterT :: proxy tag -> (m (a, w) -> n (b, w')) -> WriterT tag w m a -> WriterT tag w' n b Source
Transform the computation inside a WriterT
.
runWriterT
tag (mapWriterT
tag f m) = f (runWriterT
tag m)
Writer operations
tell :: Monad m => proxy tag -> w -> WriterT tag w m () Source
Appends a value to the accumulator within the monad.
listen :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m a -> WriterT tag w m (a, w) Source
Executes an action and adds its accumulator to the value of the computation.
pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a Source
Executes an action which returns a value and a function, and returns the value, applying the function to the accumulator.
Lifting other operations
liftCallCC :: Monoid w => proxy tag -> CallCC m (a, w) (b, w) -> CallCC (WriterT tag w m) a b Source
Lift a callCC
operation to the new monad.
liftCatch :: proxy tag -> Catch e m (a, w) -> Catch e (WriterT tag w m) a Source
Lift a catchE
operation to the new monad.