machines-0.6.1: Networked stream transducers

Copyright(C) 2012 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityRank-2 Types
Safe HaskellNone
LanguageHaskell2010

Data.Machine.Source

Contents

Description

 

Synopsis

Sources

type Source b = forall k. Machine k b Source #

A Source never reads from its inputs.

type SourceT m b = forall k. MachineT m k b Source #

A SourceT never reads from its inputs, but may have monadic side-effects.

source :: Foldable f => f b -> Source b Source #

Generate a Source from any Foldable container.

repeated :: o -> Source o Source #

Repeat the same value, over and over.

cycled :: Foldable f => f b -> Source b Source #

Loop through a Foldable container over and over.

cap :: Process a b -> Source a -> Source b Source #

You can transform a Source with a Process.

Alternately you can view this as capping the Source end of a Process, yielding a new Source.

cap l r = l <~ r

iterated :: (a -> a) -> a -> Source a Source #

iterated f x returns an infinite source of repeated applications of f to x

replicated :: Int -> a -> Source a Source #

replicated n x is a source of x emitted n time(s)

enumerateFromTo :: (Enum a, Eq a) => a -> a -> Source a Source #

Enumerate from a value to a final value, inclusive, via succ

unfold :: (r -> Maybe (a, r)) -> r -> Source a Source #

unfold k seed The function takes the element and returns Nothing if it is done producing values or returns Just (a,r), in which case, a is yielded and r is used as the next element in a recursive call.

unfoldT :: Monad m => (r -> m (Maybe (a, r))) -> r -> SourceT m a Source #

Effectful unfold variant.