pipes-2.4.0: Compositional pipelines

Control.Proxy.Prelude.Kleisli

Contents

Description

Utility functions for Kleisli arrows

Synopsis

# Core utility functions

Use foreverK to abstract away the following common pattern:

p a = do
...
a' <- respond b
p a'

Using foreverK, you can avoid the manual recursion:

p = foreverK \$ \a -> do
...
respond b

foreverK :: Monad m => (a -> m a) -> a -> m b Source #

Compose a 'K'leisli arrow with itself forever

replicateK :: Monad m => Int -> (a -> m a) -> a -> m a Source #

Repeat a 'K'leisli arrow multiple times

mapK :: (Monad m, MonadTrans t) => (a -> m b) -> a -> t m b Source #

Convenience function equivalent to (lift .)

mapK f >=> mapK g = mapK (f >=> g)

mapK return = return