machines-0.6.4: Networked stream transducers

Copyright(C) 2012 Edward Kmett Rúnar Bjarnason Paul Chiusano
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityRank-2 Types, GADTs
Safe HaskellNone
LanguageHaskell2010

Data.Machine.Wye

Contents

Description

 
Synopsis

Wyes

type Wye a b c = Machine (Y a b) c Source #

A Machine that can read from two input stream in a non-deterministic manner.

type WyeT m a b c = MachineT m (Y a b) c Source #

A Machine that can read from two input stream in a non-deterministic manner with monadic side-effects.

data Y a b c where Source #

The input descriptor for a Wye or WyeT

Constructors

X :: Y a b a 
Y :: Y a b b 
Z :: Y a b (Either a b) 

wye :: Monad m => ProcessT m a a' -> ProcessT m b b' -> WyeT m a' b' c -> WyeT m a b c Source #

Compose a pair of pipes onto the front of a Wye.

Precompose a Process onto each input of a Wye (or WyeT).

This is left biased in that it tries to draw values from the X input whenever they are available, and only draws from the Y input when X would block.

addX :: Monad m => ProcessT m a b -> WyeT m b c d -> WyeT m a c d Source #

Precompose a pipe onto the left input of a wye.

addY :: Monad m => ProcessT m b c -> WyeT m a c d -> WyeT m a b d Source #

Precompose a pipe onto the right input of a wye.

capX :: Monad m => SourceT m a -> WyeT m a b c -> ProcessT m b c Source #

Tie off one input of a wye by connecting it to a known source.

capY :: Monad m => SourceT m b -> WyeT m a b c -> ProcessT m a c Source #

Tie off one input of a wye by connecting it to a known source.

capWye :: Monad m => SourceT m a -> SourceT m b -> WyeT m a b c -> SourceT m c Source #

Tie off both inputs of a wye by connecting them to known sources.