List-0.6.1: List monad transformer and class

Safe HaskellSafe
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 a Source #

Constructors

ListT 

Fields

Instances

MonadTrans ListT Source # 

Methods

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

Monad m => Monad (ListT m) Source # 

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 #

fail :: String -> ListT m a #

Monad m => Functor (ListT m) Source # 

Methods

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

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

Monad m => Applicative (ListT m) Source # 

Methods

pure :: a -> ListT m a #

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

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

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

MonadIO m => MonadIO (ListT m) Source # 

Methods

liftIO :: IO a -> ListT m a #

Monad m => Alternative (ListT m) Source # 

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 => MonadPlus (ListT m) Source # 

Methods

mzero :: ListT m a #

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

Monad m => List (ListT m) Source # 

Associated Types

type ItemM (ListT m :: * -> *) :: * -> * Source #

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 #

Eq (m (ListItem (ListT m) a)) => Eq (ListT m a) Source # 

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 # 

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 #

Read (m (ListItem (ListT m) a)) => Read (ListT m a) Source # 
Show (m (ListItem (ListT m) a)) => Show (ListT m a) Source # 

Methods

showsPrec :: Int -> ListT m a -> ShowS #

show :: ListT m a -> String #

showList :: [ListT m a] -> ShowS #

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

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 #

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

Methods

mempty :: ListT m a #

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

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

type ItemM (ListT m) Source # 
type ItemM (ListT m) = m