Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Unassorted utilities for pipes
- arr :: Monad m => (a -> b) -> Pipe a b m r
- left :: Monad m => Pipe a b m r -> Pipe (Either a x) (Either b x) m r
- right :: Monad m => Pipe a b m r -> Pipe (Either x a) (Either x b) m r
- (+++) :: Monad m => Pipe a b m r -> Pipe c d m r -> Pipe (Either a c) (Either b d) m r
- select :: Monad m => (b -> t) -> (s -> Either t a) -> Pipe a b m r -> Pipe s t m r
- input :: Monad m => Setter (Proxy x' b y' y m r) (Proxy x' a y' y m r) a b
- output :: Monad m => Setter (Proxy x' x y' a m r) (Proxy x' x y' b m r) a b
- select' :: Monad m => Prism s t a b -> Pipe a b m r -> Pipe s t m r
- check :: Show a => Pipe a a IO r
- delay :: Double -> Pipe a a IO r
- progress :: Pipe a a IO r
- fold :: Monad m => Fold a b -> Producer a m () -> m b
- foldM :: Monad m => FoldM m a b -> Producer a m () -> m b
- scan :: Monad m => Fold a b -> Pipe a b m r
- scanM :: Monad m => FoldM m a b -> Pipe a b m r
- scan1 :: Monad m => (x -> a -> x) -> (a -> x) -> (x -> b) -> Pipe a b m r
- scan1M :: Monad m => (x -> a -> m x) -> (a -> m x) -> (x -> m b) -> Pipe a b m r
- scan1i :: Monad m => (a -> a -> a) -> Pipe a a m r
- scan1iM :: Monad m => (a -> a -> m a) -> Pipe a a m r
- toProxy :: Monad n => (forall m. Monad m => (a' -> (a -> m r) -> m r) -> (b -> (b' -> m r) -> m r) -> m r) -> Proxy a' a b' b n r
- fromProxy :: Monad m => Proxy a' a b' b m r -> (a' -> (a -> m r) -> m r) -> (b -> (b' -> m r) -> m r) -> m r
ArrowChoice
left :: Monad m => Pipe a b m r -> Pipe (Either a x) (Either b x) m r Source #
Like left
from ArrowChoice
right :: Monad m => Pipe a b m r -> Pipe (Either x a) (Either x b) m r Source #
Like right
from ArrowChoice
(+++) :: Monad m => Pipe a b m r -> Pipe c d m r -> Pipe (Either a c) (Either b d) m r Source #
Like (+++
) from ArrowChoice
pL +++ pR = left pL >-> right pR
select :: Monad m => (b -> t) -> (s -> Either t a) -> Pipe a b m r -> Pipe s t m r Source #
Feed some values into a pipe and let the rest pass by
Lenses
input :: Monad m => Setter (Proxy x' b y' y m r) (Proxy x' a y' y m r) a b Source #
It helps to think in terms of the following simpler types:
input :: Monad m => Setter' (Consumer a m r) a input :: Monad m => Setter' (Pipe a b m r) a
Note: This only works with lens
and not lens-family-core
output :: Monad m => Setter (Proxy x' x y' a m r) (Proxy x' x y' b m r) a b Source #
It helps to think in terms of the following simpler types:
output :: Monad m => Setter' (Producer b m r) b output :: Monad m => Setter' (Pipe a b m r) b
Note: This only works with lens
and not lens-family-core
Fun
check :: Show a => Pipe a a IO r Source #
Ask whether or not to let values pass through
>>>
runEffect $ each [1..3] >-> check >-> Pipes.print
Allow <1> [Y/n]? y<Enter> 1 Allow <2> [Y/n]? no<Enter> Allow <3> [Y/n]? YES<Enter> 3
progress :: Pipe a a IO r Source #
Display a progress bar
This is very simple and only works if nothing else writes to the terminal
Try this:
>>>
runEffect $ each [1..] >-> progress >-> delay 0.1 >-> Pipes.Prelude.drain
Foldl Compatibility
Note that you can already mix the pipes
and foldl
libraries without
using pipes-extras
just by using:
import Control.Foldl (purely) import Pipes.Prelude (fold) purely fold :: Monad m => Fold a b -> Producer a m () -> m b
The following functions are for people who are too lazy to do even that.
fold :: Monad m => Fold a b -> Producer a m () -> m b Source #
Strict fold of the elements of a Producer
foldM :: Monad m => FoldM m a b -> Producer a m () -> m b Source #
Strict, monadic fold of the elements of a Producer
Fold Variations
These are minor variations on left folds / scans
scan1 :: Monad m => (x -> a -> x) -> (a -> x) -> (x -> b) -> Pipe a b m r Source #
Strict left scan without explicit initial state
scan1M :: Monad m => (x -> a -> m x) -> (a -> m x) -> (x -> m b) -> Pipe a b m r Source #
Strict, monadic left scan without explicit initial state
scan1i :: Monad m => (a -> a -> a) -> Pipe a a m r Source #
Strict, endomorphic left scan without explicit initial state.
-- Compute exponential moving average ema :: (Monad m, Fractional a) => a -> Pipe a a m r ema α = scan1i (\last input -> last * α + input * (1 - α))
scan1iM :: Monad m => (a -> a -> m a) -> Pipe a a m r Source #
Strict, monadic and endomorphic left scan without explicit initial state