yampa-test-0.13.2: Testing library for Yampa.
Safe HaskellNone
LanguageHaskell2010

FRP.Yampa.Stream

Description

Streams and stream manipulation API.

The evaluation of Yampa SFs, especially for testing purposes, needs the generation of suitable input streams.

While some streams can be generated randomly using QuickCheck, it is sometimes useful to be able to preprend or adapt an input stream. It is also useful to debug programs when you have recorded input streams using Haskell Titan.

This module defines types for input streams, as well as an API to create, examine and combine streams. It also provides evaluation functions that are needed to apply an SF to a stream and obtain an output stream and a continuation SF.

Synopsis

Types

type SignalSampleStream a = (a, FutureSampleStream a) Source #

A stream of samples, with their sampling times.

type FutureSampleStream a = [(DTime, a)] Source #

A stream of future samples, with their sampling times. The difference between SignalSampleStream and FutureSampleStream is that all elements in the latter have a non-zero time delta.

Creation

groupDeltas :: [a] -> [DTime] -> SignalSampleStream a Source #

Group a series of samples with a series of time deltas.

The first sample will have no delta. Unused samples and deltas will be dropped.

Examination

samples :: SignalSampleStream a -> [a] Source #

Turn a stream with sampling times into a list of values.

firstSample :: SignalSampleStream a -> a Source #

Return the first sample in a sample stream.

lastSample :: SignalSampleStream a -> a Source #

Return the last sample in a sample stream.

Manipulation

sMerge :: (a -> a -> a) -> SignalSampleStream a -> SignalSampleStream a -> SignalSampleStream a Source #

Merge two streams, using an auxilary function to merge samples that fall at the exact same sampling time.

sConcat :: SignalSampleStream a -> DTime -> SignalSampleStream a -> SignalSampleStream a Source #

Concatenate two sample streams, separating them by a given time delta.

sRefine :: DTime -> SignalSampleStream a -> SignalSampleStream a Source #

Refine a stream by establishing the maximum time delta.

If two samples are separated by a time delta bigger than the given max DT, the former is replicated as many times as necessary.

sRefineWith :: (a -> a -> a) -> DTime -> SignalSampleStream a -> SignalSampleStream a Source #

Refine a stream by establishing the maximum time delta.

If two samples are separated by a time delta bigger than the given max DT, the auxiliary interpolation function is used to determine the intermendiate sample.

sClipAfterFrame :: Int -> SignalSampleStream a -> SignalSampleStream a Source #

Clip a sample stream at a given number of samples.

sClipAfterTime :: DTime -> SignalSampleStream a -> SignalSampleStream a Source #

Clip a sample stream after a certain (non-zero) time.

sClipBeforeFrame :: Int -> SignalSampleStream a -> SignalSampleStream a Source #

Drop the first n samples of a signal stream. The time deltas are not re-calculated.

sClipBeforeTime :: DTime -> SignalSampleStream a -> SignalSampleStream a Source #

Drop the first samples of a signal stream up to a given time. The time deltas are not re-calculated to match the original stream.

Stream-based evaluation

evalSF :: SF a b -> SignalSampleStream a -> (SignalSampleStream b, FutureSF a b) Source #

Evaluate an SF with a SignalSampleStream, obtaining an output stream and a continuation.

You should never use this for actual execution in your applications, only for testing.

evalFutureSF :: FutureSF a b -> FutureSampleStream a -> (FutureSampleStream b, FutureSF a b) Source #

Evaluate an initialised SF with a FutureSampleStream, obtaining an output stream and a continuation.

You should never use this for actual execution in your applications, only for testing.