boombox-0.0: Chronokinetic stream sources and incremental consumers

Safe HaskellSafe
LanguageHaskell2010

Data.Boombox.Tape

Contents

Synopsis

Documentation

newtype Tape w m a Source

Tape w m a is a producer of values with a type a. It may cause effects m and has a comonadic control w.

Constructors

Tape 

Fields

unconsTape :: m (a, w (Tape w m a))
 

Instances

Consuming tapes

headTape :: Functor m => Tape w m a -> m a Source

Take the first element of the tape.

cueTape :: (Comonad w, Applicative m) => Tape w m a -> m (w (Tape w m a)) Source

Denudate the control without dropping a value.

Constructing tapes

yield :: Applicative m => a -> w (Tape w m a) -> Tape w m a Source

yieldMany :: (Comonad w, Foldable f, Applicative m) => f a -> w (Tape w m a) -> Tape w m a Source

effect :: Monad m => m (Tape w m a) -> Tape w m a Source

repeater :: (Functor m, Comonad w) => m (w a) -> Tape w m a Source

Build a tape that yields the same value, with the very same effect and exactly the same control.

Transforming tapes

flattenTape :: (Comonad w, Foldable f, Monad m) => Tape w m (f a) -> Tape w m a Source

Flatten a tape of Foldable containers.

filterTape :: (Comonad w, Monad m) => (a -> Bool) -> Tape w m a -> Tape w m a Source

foldTape :: (Comonad w, Foldable f, Monad m) => (a -> f b) -> Tape w m a -> Tape w m b Source

hoistTransTape :: (Functor w, Functor n) => (forall x. v x -> w x) -> (forall x. m x -> n x) -> Tape v m a -> Tape w n a Source

hoistTape :: (Functor w, Functor m) => (forall x. v x -> w x) -> Tape v m a -> Tape w m a Source

Apply natural transformation to the comonadic control surface.

transTape :: (Functor w, Functor n) => (forall x. m x -> n x) -> Tape w m a -> Tape w n a Source

Transform effects produced by the tape.

controlTape :: Functor m => (w (Tape w m a) -> w (Tape w m a)) -> Tape w m a -> Tape w m a Source

Operate on the control surface just once.

pushBack :: (Foldable f, Comonad w, Monad m) => f a -> Tape w m a -> Tape w m a Source

Push some values back to a tape.

intercept :: (Functor w, Monad m) => (a -> m b) -> Tape w m a -> Tape w m b Source

Apply a monadic function to a tape.

Time series

class Functor f => Chronological f where Source

Chronological functor is like Apply, but the operation may fail due to a time lag.

Methods

coincidence :: f a -> f b -> EventOrder (f (a, b)) Source