List-0.6.2: List monad transformer and class

Safe Haskell | Safe-Inferred
Language | Haskell98

Control.Monad.ListT

Description

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.

# Documentation

newtype ListT (m :: Type -> Type) a Source #

Constructors

ListT |

Fields

- runListT :: m (ListItem (ListT m) a)

#### Instances

Instances details

MonadTrans ListT Source # |
Instance details Defined in Control.Monad.ListT Methods lift :: Monad m => m a -> ListT m a Source #
Monad m => List (ListT m) Source # |

Instance details

Defined in Control.Monad.ListT

Associated Types

type ItemM (ListT m) |
Instance details Defined in Control.Monad.ListT type ItemM (ListT m) = m

Methods

runList :: ListT m a -> ItemM (ListT m) (ListItem (ListT m) a) Source #

joinL :: ItemM (ListT m) (ListT m a) -> ListT m a Source #

cons :: a -> ListT m a -> ListT m a Source #

MonadIO m => MonadIO (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods liftIO :: IO a -> ListT m a Source #
Monad m => Alternative (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods empty :: ListT m a Source # (<|>) :: ListT m a -> ListT m a -> ListT m a Source # some :: ListT m a -> ListT m [a] Source # many :: ListT m a -> ListT m [a] Source #
Monad m => Applicative (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods pure :: a -> ListT m a Source # (<*>) :: ListT m (a -> b) -> ListT m a -> ListT m b Source # liftA2 :: (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c Source # (*>) :: ListT m a -> ListT m b -> ListT m b Source # (<*) :: ListT m a -> ListT m b -> ListT m a Source #
Functor m => Functor (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods fmap :: (a -> b) -> ListT m a -> ListT m b Source # (<$) :: a -> ListT m b -> ListT m a Source #
Monad m => Monad (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods (>>=) :: ListT m a -> (a -> ListT m b) -> ListT m b Source # (>>) :: ListT m a -> ListT m b -> ListT m b Source # return :: a -> ListT m a Source #
Monad m => MonadPlus (ListT m) Source # |
Instance details Defined in Control.Monad.ListT Methods mzero :: ListT m a Source # mplus :: ListT m a -> ListT m a -> ListT m a Source #
Monad m => Monoid (ListT m a) Source # |
Instance details Defined in Control.Monad.ListT Methods mempty :: ListT m a Source # mappend :: ListT m a -> ListT m a -> ListT m a Source # mconcat :: [ListT m a] -> ListT m a Source #
Monad m => Semigroup (ListT m a) Source # |
Instance details Defined in Control.Monad.ListT Methods (<>) :: ListT m a -> ListT m a -> ListT m a Source # sconcat :: NonEmpty (ListT m a) -> ListT m a Source # stimes :: Integral b => b -> ListT m a -> ListT m a Source #
Read (m (ListItem (ListT m) a)) => Read (ListT m a) Source # |
Instance details Defined in Control.Monad.ListT Methods readsPrec :: Int -> ReadS (ListT m a) Source # readList :: ReadS [ListT m a] Source # readPrec :: ReadPrec (ListT m a) Source # readListPrec :: ReadPrec [ListT m a] Source #
Show (m (ListItem (ListT m) a)) => Show (ListT m a) Source # |
Instance details Defined in Control.Monad.ListT Methods showsPrec :: Int -> ListT m a -> ShowS Source # show :: ListT m a -> String Source # showList :: [ListT m a] -> ShowS Source #
Eq (m (ListItem (ListT m) a)) => Eq (ListT m a) Source # |
Instance details Defined in Control.Monad.ListT Methods (==) :: ListT m a -> ListT m a -> Bool Source # (/=) :: ListT m a -> ListT m a -> Bool Source #
Ord (m (ListItem (ListT m) a)) => Ord (ListT m a) Source # |

Instance details

Defined in Control.Monad.ListT

Methods

compare :: ListT m a -> ListT m a -> Ordering Source #

(<) :: ListT m a -> ListT m a -> Bool Source #

(<=) :: ListT m a -> ListT m a -> Bool Source #

(>) :: ListT m a -> ListT m a -> Bool Source #

(>=) :: ListT m a -> ListT m a -> Bool Source #

max :: ListT m a -> ListT m a -> ListT m a Source #

min :: ListT m a -> ListT m a -> ListT m a Source #

type ItemM (ListT m) Source # |
Instance details Defined in Control.Monad.ListT type ItemM (ListT m) = m