list of results monad

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
12 Mar 2001 14:08:50 GMT


Mon, 12 Mar 2001 02:28:11 +0100, Hannah Schroeter <uk1o@rz.uni-karlsruhe.de> pisze:

> I *did* do a result monad once (for data compression, in fact
> the monad was combined for "imperatively" consuming input as well
> as "imperatively" producing output).

These monads are present in ghc >= 4.06, in -package lang, modules:
    MonadReader
    MonadWriter
    MonadState
    MonadRWS

The combination of state and output can be done as one of these:
    WriterT w (State s)
    StateT s (Writer w)
    RWS () w s
where w is the type of output and must be a monoid (e.g. a list)
and s is the type of state.

> data ResultM r a = RM (r -> (r,a))

This is isomorphic to MonadState.State.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK