drinkery-0.2.1: Boozy streaming library

Safe HaskellSafe
LanguageHaskell2010

Data.Drinkery.Distiller

Contents

Synopsis

Documentation

type Distiller tap r s m = Tap r s (Drinker 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 -> Drinker tap m a -> m a infix 6 Source #

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

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

Like (+&) but discards the used tap.

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

Basic combinators

(++$) :: Functor 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.

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

Connect a tap with a Drinker. Flipped runDrinker.

Mnemonic:

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

Stock distillers

reservingTap :: MonadDrunk (Tap r a) m => (a -> m (s, Tap r s m)) -> Tap r s 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 :: (MonadDrunk (Tap r a) m, Semigroup r) => m b -> Tap r b m Source #

Create a request-preserving distiller from a drinker action.