List-0.6.2: List monad transformer and class
Safe HaskellSafe-Inferred
LanguageHaskell98

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

Instances

Instances details
MonadTrans ListT Source # 
Instance details

Defined in Control.Monad.ListT

Methods

lift :: Monad m => m a -> ListT m a

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

Monad m => Alternative (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

empty :: ListT m a

(<|>) :: ListT m a -> ListT m a -> ListT m a

some :: ListT m a -> ListT m [a]

many :: ListT m a -> ListT m [a]

Monad m => Applicative (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

pure :: a -> ListT m a

(<*>) :: ListT m (a -> b) -> ListT m a -> ListT m b

liftA2 :: (a -> b -> c) -> ListT m a -> ListT m b -> ListT m c

(*>) :: ListT m a -> ListT m b -> ListT m b

(<*) :: ListT m a -> ListT m b -> ListT m a

Functor m => Functor (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

fmap :: (a -> b) -> ListT m a -> ListT m b

(<$) :: a -> ListT m b -> ListT m a

Monad m => Monad (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

(>>=) :: ListT m a -> (a -> ListT m b) -> ListT m b

(>>) :: ListT m a -> ListT m b -> ListT m b

return :: a -> ListT m a

Monad m => MonadPlus (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

mzero :: ListT m a

mplus :: ListT m a -> ListT m a -> ListT m a

Monad m => Monoid (ListT m a) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

mempty :: ListT m a

mappend :: ListT m a -> ListT m a -> ListT m a

mconcat :: [ListT m a] -> ListT m a

Monad m => Semigroup (ListT m a) Source # 
Instance details

Defined in Control.Monad.ListT

Methods

(<>) :: ListT m a -> ListT m a -> ListT m a

sconcat :: NonEmpty (ListT m a) -> ListT m a

stimes :: Integral b => b -> ListT m a -> ListT m a

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)

readList :: ReadS [ListT m a]

readPrec :: ReadPrec (ListT m a)

readListPrec :: ReadPrec [ListT m a]

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

show :: ListT m a -> String

showList :: [ListT m a] -> ShowS

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

(/=) :: ListT m a -> ListT m a -> Bool

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

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

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

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

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

max :: ListT m a -> ListT m a -> ListT m a

min :: ListT m a -> ListT m a -> ListT m a

type ItemM (ListT m) Source # 
Instance details

Defined in Control.Monad.ListT

type ItemM (ListT m) = m