Rattus-0.3.1: A modal FRP language

Safe HaskellNone
LanguageHaskell2010

Rattus.Stream

Description

Programming with streams.

Synopsis

Documentation

map :: Box (a -> b) -> Str a -> Str b Source #

Apply a function to each element of a stream.

hd :: Str a -> a Source #

Get the first element (= head) of a stream.

tl :: Str a -> O (Str a) Source #

Get the tail of a stream, i.e. the remainder after removing the first element.

const :: Stable a => a -> Str a Source #

Construct a stream that has the same given value at each step.

constBox :: Box a -> Str a Source #

Variant of const that allows any type a as argument as long as it is boxed.

shift :: Stable a => a -> Str a -> Str a Source #

Given a value a and a stream as, this function produces a stream that behaves like

shiftMany :: Stable a => List a -> Str a -> Str a Source #

Given a list [a1, ..., an] of elements and a stream xs this function constructs a stream that starts with the elements a1, ..., an, and then proceeds as xs. In particular, this means that the ith element of the original stream xs is the (i+n)th element of the new stream. In other words shiftMany behaves like repeatedly applying shift for each element in the list.

scan :: Stable b => Box (b -> a -> b) -> b -> Str a -> Str b Source #

Similar to Haskell's scanl.

scan (box f) x (v1 ::: v2 ::: v3 ::: ... ) == (x `f` v1) ::: ((x `f` v1) `f` v2) ::: ...

Note: Unlike scanl, scan starts with x f v1, not x.

scanMap :: Stable b => Box (b -> a -> b) -> Box (b -> c) -> b -> Str a -> Str c Source #

scanMap is a composition of map and scan:

scanMap f g x === map g . scan f x

scanMap2 :: Stable b => Box (b -> a1 -> a2 -> b) -> Box (b -> c) -> b -> Str a1 -> Str a2 -> Str c Source #

scanMap2 is similar to scanMap but takes two input streams.

data Str a Source #

Str a is a stream of values of type a.

Constructors

!a ::: !(O (Str a)) 

zipWith :: Box (a -> b -> c) -> Str a -> Str b -> Str c Source #

Similar to zipWith on Haskell lists.

zip :: Str a -> Str b -> Str (a :* b) Source #

Similar to zip on Haskell lists.

unfold :: Stable a => Box (a -> a) -> a -> Str a Source #

Construct a stream by repeatedly applying a function to a given start element. That is, unfold (box f) x will produce the stream x ::: f x ::: f (f x) ::: ...

filter :: Box (a -> Bool) -> Str a -> Str (Maybe' a) Source #

Filter out elements from a stream according to a predicate.

integral :: (Stable a, VectorSpace a s) => a -> Str s -> Str a -> Str a Source #

Calculates an approximation of an integral of the stream of type Str a (the y-axis), where the stream of type Str s provides the distance between measurements (i.e. the distance along the y axis).