Module

Uncurried.WriterT

Package
purescript-uncurried-transformers
Repository
PureFunctor/purescript-uncurried-transformers

This module defines the writer monad transformer, WriterT.

#WriterT Source

newtype WriterT :: Type -> (Type -> Type) -> Type -> Typenewtype WriterT w m a

The writer monad transformer, implemented as a newtype over RWSET. Note that it's not recommended to stack newtypes of RWSET together as it incurs an indeterminate performance penalty that would otherwise be solved by just using RWSET.

Constructors

Instances

#writerT Source

writerT :: forall w m a. Functor m => Monoid w => m (a /\ w) -> WriterT w m a

Create a Writer monad from a pair of a result and an accumulator.

#runWriterT Source

runWriterT :: forall w m a. Monoid w => MonadRec m => WriterT w m a -> m (a /\ w)

Runs a computation inside of WriterT.

#evalWriterT Source

evalWriterT :: forall w m a. Monoid w => MonadRec m => WriterT w m a -> m a

Runs a computation inside of WriterT, discarding the final accumulator.

#execWriterT Source

execWriterT :: forall w m a. Monoid w => MonadRec m => WriterT w m a -> m w

Runs a computation inside of WriterT, discarding the final result.

#hoistWriterT Source

hoistWriterT :: forall w m n a. (m ~> n) -> WriterT w m a -> WriterT w n a

Modifies the monadic context of a WriterT.

#mapWriterT Source

mapWriterT :: forall w1 w2 m1 m2 a1 a2. Monoid w1 => Monoid w2 => MonadRec m1 => Functor m2 => (m1 (a1 /\ w1) -> m2 (a2 /\ w2)) -> WriterT w1 m1 a1 -> WriterT w2 m2 a2

Modifies the result and accumulator types of a WriterT.