Agda-2.4.2.4: A dependently typed functional programming language and proof assistant

Safe HaskellNone
LanguageHaskell98

Agda.Utils.ListT

Contents

Description

ListT done right, see https://www.haskell.org/haskellwiki/ListT_done_right_alternative

There is also the list-t package on hackage (Nikita Volkov) but it again depends on other packages we do not use yet, so we rather implement the few bits we need afresh.

Synopsis

Documentation

newtype ListT m a Source

Lazy monadic computation of a list of results.

Constructors

ListT 

Fields

runListT :: m (Maybe (a, ListT m a))
 

Instances

MonadTrans ListT Source 
(Applicative m, MonadState s m) => MonadState s (ListT m) Source 
(Applicative m, MonadReader r m) => MonadReader r (ListT m) Source 
(Functor m, Applicative m, Monad m) => Monad (ListT m) Source 
Functor m => Functor (ListT m) Source 
(Functor m, Applicative m, Monad m) => Applicative (ListT m) Source 
(Functor m, Applicative m, Monad m) => Alternative (ListT m) Source 
(Functor m, Applicative m, Monad m) => MonadPlus (ListT m) Source 
(Applicative m, MonadIO m) => MonadIO (ListT m) Source 
MonadTCM tcm => MonadTCM (ListT tcm) Source 
Monad m => Monoid (ListT m a) Source 

List operations

nilListT :: Monad m => ListT m a Source

The empty lazy list.

consListT :: Monad m => a -> ListT m a -> ListT m a Source

Consing a value to a lazy list.

sgListT :: Monad m => a -> ListT m a Source

Singleton lazy list.

caseListT :: Monad m => ListT m a -> m b -> (a -> ListT m a -> m b) -> m b Source

Case distinction over lazy list.

foldListT :: Monad m => (a -> m b -> m b) -> m b -> ListT m a -> m b Source

Folding a lazy list, effects left-to-right.

concatListT :: Monad m => ListT m (ListT m a) -> ListT m a Source

The join operation of the ListT m monad.

Monadic list operations.

runMListT :: Monad m => m (ListT m a) -> ListT m a Source

We can `run' a computation of a ListT as it is monadic itself.

consMListT :: Monad m => m a -> ListT m a -> ListT m a Source

Monadic cons.

sgMListT :: Monad m => m a -> ListT m a Source

Monadic singleton.

mapMListT :: Monad m => (a -> m b) -> ListT m a -> ListT m b Source

Extending a monadic function to ListT.

mapMListT_alt :: Monad m => (a -> m b) -> ListT m a -> ListT m b Source

Alternative implementation using foldListT.