pipes-3.2.0: Compositional pipelines

Control.Proxy.Prelude.Kleisli

Contents

Description

Utility functions for Kleisli arrows

Synopsis

# Core utility functions

foreverK :: Monad m => (a -> m a) -> a -> m bSource

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 aSource

Repeat a '`K`'leisli arrow multiple times

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

Convenience function equivalent to `(lift .)`

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

liftK return = return
```

Arguments

 :: (Monad m, MFunctor t) => (forall a. m a -> n a) Monad morphism -> (b' -> t m b) Kleisli arrow -> b' -> t n b

Convenience function equivalent to `(hoist f .)`

raise :: (Monad m, MFunctor t1, MonadTrans t2) => t1 m r -> t1 (t2 m) rSource

Lift the base monad

``` raise = hoist lift
```

raiseK :: (Monad m, MFunctor t1, MonadTrans t2) => (q -> t1 m r) -> q -> t1 (t2 m) rSource

Lift the base monad of a '`K`'leisli arrow

``` raiseK = hoistK lift
```

Arguments

 :: (Monad m, Proxy p1, PFunctor t) => (forall r1. p1 a' a b' b m r1 -> p2 a' a b' b n r1) Proxy morphism -> (q -> t p1 a' a b' b m r2) Proxy Kleisli arrow -> q -> t p2 a' a b' b n r2

Convenience function equivalent to `(hoistP f .)`

Arguments

 :: (Monad m, Proxy p, PFunctor t1, ProxyTrans t2) => t1 p a' a b' b m r Proxy -> t1 (t2 p) a' a b' b m r

Lift the base proxy

``` raiseP = hoistP liftP
```

Arguments

 :: (Monad m, Proxy p, PFunctor t1, ProxyTrans t2) => (q -> t1 p a' a b' b m r) Proxy Kleisli arrow -> q -> t1 (t2 p) a' a b' b m r

Lift the base proxy of a '`K`'leisli arrow

``` raisePK = hoistPK liftP
```