Copyright | (c) Andy Gill 2001 (c) Oregon Graduate Institute of Science and Technology 2001 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable (type families) |
Safe Haskell | None |
Language | GHC2021 |
Control.Monad.Writer.Class
Description
The MonadWriter class.
Inspired by the paper /Functional Programming with Overloading and Higher-Order Polymorphism/, Mark P Jones (http://web.cecs.pdx.edu/~mpj/pubs/springschool.html) Advanced School of Functional Programming, 1995.
Synopsis
- class (Monoid (WriterType m), Monad m) => MonadWriter (m :: Type -> Type) where
- type WriterType (m :: Type -> Type)
- tell :: WriterType m -> m ()
- listen :: m a -> m (a, WriterType m)
- pass :: m (a, WriterType m -> WriterType m) -> m a
- listens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b)
- censor :: MonadWriter m => (WriterType m -> WriterType m) -> m a -> m a
Documentation
class (Monoid (WriterType m), Monad m) => MonadWriter (m :: Type -> Type) where Source #
Associated Types
type WriterType (m :: Type -> Type) Source #
Methods
tell :: WriterType m -> m () Source #
Shout to the monad what you want to be heard. The monad carries
this packet upwards, merging it if needed (hence the Monoid
requirement).
listen :: m a -> m (a, WriterType m) Source #
Listen to a monad acting, and return what the monad "said".
pass :: m (a, WriterType m -> WriterType m) -> m a Source #
Provide a writer transformer which changes internals of the written object.
Instances
listens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b) Source #
censor :: MonadWriter m => (WriterType m -> WriterType m) -> m a -> m a Source #