HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Modulelist-t-1.0.5.7Haskell2010

ListT

Contents
  1. Execution utilities
  2. Construction utilities
  3. Transformation utilities
Synopsis
  • Packagelist-t-1.0.5.7
  • Exports24
  • LanguageHaskell2010
  • LicenceMIT
  • SourceListT.hs
newtypenewtype ListT (m :: Type -> Type) a

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.

Constructors

Instances32MonadTrans, MMonad, MFunctor, MonadError, MonadReader, MonadState, …

Execution utilities

valueuncons :: ListT m a -> m (Maybe (a, ListT m a))

Execute in the inner monad, getting the head and the tail. Returns nothing if it's empty.

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

Execute, applying a strict left fold.

valuetraverse_ :: Monad m => (a -> m ()) -> ListT m a -> m ()

Execute, traversing the stream with a side effect in the inner monad.

valuesplitAt :: Monad m => Int -> ListT m a -> m ([a], ListT m a)

Execute, consuming a list of the specified length and returning the remainder stream.

Construction utilities

valueunfoldM :: Monad m => (b -> m (Maybe (a, b))) -> b -> ListT m a

Construct by unfolding a monadic data structure

This is the most memory-efficient way to construct ListT where the length depends on the inner monad.

Transformation utilities

These utilities only accumulate the transformations without actually traversing the stream. They only get applied in a single traversal, which only happens at the execution.

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

A transformation, which traverses the stream with an action in the inner monad.