drinkery-0.4: Boozy streaming library

Safe HaskellSafe
LanguageHaskell2010

Data.Drinkery.Distiller

Contents

Synopsis

Documentation

type Distiller tap r s m = Tap r s (Sink tap m) Source #

Distiller tap m r s is a stream transducer which has four parameters:

  • tap input
  • r request from the downstream
  • s output
  • m underlying monad

This is also a Tap.

Special combinators

(+&) :: (Closable tap, MonadCatch m) => tap m -> Sink tap m a -> m a infix 6 Source #

Feed a tap to a drinker and close the used tap.

($&) :: Monad m => tap m -> Sink tap m a -> m a infixr 7 Source #

Like (+&) but discards the used tap.

($&) :: Distiller tap m r s -> Sink (Tap r s) (Sink tap m) a -> Sink tap m a

Basic combinators

(++$) :: Applicative m => tap m -> Distiller tap r s m -> Tap r s m infixl 8 Source #

Attach a distiller to a tap.

Mnemonic:

  • + Left operand is a tap.
  • + Returns a tap.
  • $ Right operand is a distiller.

(++&) :: Applicative m => tap m -> Sink tap m a -> m (tap m, a) infixr 7 Source #

Connect a tap with a Sink. Flipped runSink.

Mnemonic:

  • + Left operand is a tap.
  • + Returns a tap (along with the result).
  • & Right operand is a Sink.

Stock distillers

reservingTap :: Monad m => (a -> Sink (Tap r a) m (b, Distiller (Tap r a) r b m)) -> Distiller (Tap r a) r b m Source #

Get one element preserving a request

echo :: Monad m => Distiller (Tap r s) r s m Source #

mapping :: Monad m => (a -> b) -> Distiller (Tap r a) r b m Source #

traversing :: Monad m => (a -> m b) -> Distiller (Tap r a) r b m Source #

filtering :: (Monoid r, Monad m) => (a -> Bool) -> Distiller (Tap r a) r a m Source #

scanning :: Monad m => (b -> a -> b) -> b -> Distiller (Tap r a) r b m Source #

repeating :: (MonadSink (Tap r a) m, Semigroup r) => m b -> Tap r b m Source #

Create a request-preserving distiller from a drinker action.