linsyking/elm-monad/1.0.0

NOTE: the latest version is 1.0.1

Monad.Writer

Writer Monad

The definition of writer monad in Haskell is

newtype Writer w a = Writer { runWriter :: (a,w) }

where w should be monoid (with mappend function).

We assume you only use List so we replace w with List w

type Writer w a
= Writer ( a, List w )

Writer

return : a -> Writer w a

return function for Writer

runWriter : Writer w a -> ( a, List w )

Run the writer

bind : Writer w a -> (a -> Writer w b) -> Writer w b

bind function for Writer

tell : List w -> Writer w ()

tell function for Writer