pipes-3.1.0: Compositional pipelines

Safe HaskellSafe
LanguageHaskell98

Control.Proxy.Prelude.Kleisli

Contents

Description

Utility functions for Kleisli arrows

Synopsis

Core utility functions

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

Compose a 'K'leisli arrow with itself forever

Use foreverK to abstract away the following common recursion pattern:

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

Using foreverK, you can instead write:

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

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

Repeat a 'K'leisli arrow multiple times

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

Convenience function equivalent to (lift .)

liftK f >=> liftK g = liftK (f >=> g)

liftK return = return