drinkery-0.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, Monad 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

type Still p q r s m = Distiller (Tap p q) r s m Source #

Mono in/out

scanningMaybe :: (Monoid r, Monad m) => (b -> a -> b) -> b -> Still r (Maybe a) r (Maybe b) m Source #

filteringMaybe :: (Monoid r, Monad m) => (a -> Bool) -> Still r (Maybe a) r (Maybe a) m Source #

mapping :: (Monoid r, Monad m) => (a -> b) -> Still r a r b m Source #

traversing :: (Monoid r, Monad m) => (a -> m b) -> Still r a r b m Source #

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

scanning :: (Monoid r, Monad m) => (b -> a -> b) -> b -> Still r a r b m Source #