A list monad transformer / a monadic list.
Monadic list example: A program which reads numbers from the user and
accumulates them.
import Control.Monad.ListT.Funcs (repeatM)
import Data.List.Class (execute, scanl, takeWhile, mapL)
import Prelude hiding (scanl, takeWhile)
main =
execute . mapL print .
scanl (+) 0 .
fmap (fst . head) .
takeWhile (not . null) .
fmap reads $ repeatM getLine
Note: The
transformers package also has a
ListT type,
which oddly enough it is not a list monad transformer. This module was
deliberately named differently from
transformers's module.