ListT -package:list-transformer
A generator with side-effects.
The list monad transformer, which extends a monad with non-determinism
The type variables signify:
- m - The base monad
- a - The values that the computation yields
throughout its execution
For basic construction and composition of
ListT computations,
much can be accomplished using common typeclass methods.
- return corresponds to yield, yielding a single
value.
- (>>=) corresponds to for, calling the second
computation once for each time the first computation
yields.
- mempty neither yields any values nor produces any
effects in the base monad.
- (<>) sequences two computations, yielding all
the values of the first followed by all the values of the second.
- lift converts an action in the base monad into a ListT
computation which performs the action and yields a single
value.
ListT is a newtype wrapper for
Producer. You will likely
need to use
Select and
enumerate to convert back and
forth between these two types to take advantage of all the
Producer-related utilities that
Pipes.Prelude has to
offer.
A proper implementation of the list monad-transformer. Useful for
streaming of monadic data structures.
Since it has instances of
MonadPlus and
Alternative, you
can use general utilities packages like
"monadplus" with it.
Lazy monadic computation of a list of results.
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.
Not on Stackage, so not searched.
List transformer
Stream the associations passively.
Stream the associations passively.
Stream associations passively.
Stream the elements passively.
This option, when set to
True, specifies that we should run in
the «list tests» mode.