pipes-2.5.0: Compositional pipelines

Safe HaskellSafe-Inferred

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 bSource

Compose a 'K'leisli arrow with itself forever

replicateK :: Monad m => Int -> (a -> m a) -> a -> m aSource

Repeat a 'K'leisli arrow multiple times

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

Convenience function equivalent to (lift .)

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

 mapK return = return