tcalculus-1.0.0: A DSL prototype for structured realtime/reactive functional programing

Copyright(c) David Janin, Simon Archipoff, 2016
Licensesee the LICENSE file in the distribution
Maintainerjanin@labri.fr
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Tile.QList

Contents

Description

QLists are timed sequences of bundles of temporal values, that is, lists of Atoms synchronized on their starts, separated by (positive) delays. QLists are in one to one correspondance with zero duration tiles with no anticipation.

QLists form the back-end of our reactive machinery. Combining qlists can be directly made by using functions like mergeQ or insertQ. However, the algebraic properties of these functions are not as nice as those acting over tiles (see Docs.Additive). So tiles can be seen as a handy algebraic front-end for qlist manipulation.

In the above picture of a tile, the underlying qlist is depicted in black. There is a semantic embedding of qlist into tile by the mapping

fromQList q = Tile 0 0 q

Synopsis

Timed "list" of temporal values

data QList d iv v where Source #

Queue lists (in short qlists) are built over duration type d, input value type iv and ouput value type v

Constructors

QEnd :: QList d iv v 
QList :: [Atom d iv v] -> DQ d iv v -> QList d iv v 
QRec :: Updatable p d iv => d -> (p -> QList d iv v) -> p -> QList d iv v 

Instances

Num d => Functor (QList d iv) Source # 

Methods

fmap :: (a -> b) -> QList d iv a -> QList d iv b #

(<$) :: a -> QList d iv b -> QList d iv a #

(Num d, Eq d, POrd d, POrd v) => Eq (QList d iv v) Source #

Semantical equality, possibly unfolding recursive definitions.

Methods

(==) :: QList d iv v -> QList d iv v -> Bool #

(/=) :: QList d iv v -> QList d iv v -> Bool #

(Show d, Num d, Show v) => Show (QList d iv v) Source #

Show instance

Methods

showsPrec :: Int -> QList d iv v -> ShowS #

show :: QList d iv v -> String #

showList :: [QList d iv v] -> ShowS #

(Num d, Eq d, POrd d, POrd v) => POrd (QList d iv v) Source #

Derived natural partial order, possibly unfolding recursive definitions.

Methods

partialCompare :: QList d iv v -> QList d iv v -> Maybe Ordering Source #

pLeq :: QList d iv v -> QList d iv v -> Bool Source #

pOrdEq :: QList d iv v -> QList d iv v -> Bool Source #

pOrdMin :: [QList d iv v] -> Maybe (QList d iv v) Source #

pOrdMax :: [QList d iv v] -> Maybe (QList d iv v) Source #

pOrdReduceMin :: [QList d iv v] -> [QList d iv v] Source #

pOrdReduceMax :: [QList d iv v] -> [QList d iv v] Source #

Updatable (QList d iv v) d iv Source #

For on-the fly updates of outputs

Methods

update :: UpdateData d iv -> QList d iv v -> QList d iv v Source #

size_qlist :: QList t t1 t2 -> Int Source #

width_qlist :: QList t t1 t2 -> Int Source #

data DQ d iv v Source #

Delayed qlists, built over duration type d and input value type iv with invariant property

In every value (DQ d iv v) we should have (partialCompare 0 d) either equals Just LT or Just EQ

Constructors

DQ d (QList d iv v) 

Instances

(Num d, Show d, Show v) => Show (DQ d iv v) Source # 

Methods

showsPrec :: Int -> DQ d iv v -> ShowS #

show :: DQ d iv v -> String #

showList :: [DQ d iv v] -> ShowS #

(Num d, Eq d, POrd d, POrd v) => POrd (DQ d iv v) Source #

Derived natural partial order, possibly unfolding recursive definitions.

Methods

partialCompare :: DQ d iv v -> DQ d iv v -> Maybe Ordering Source #

pLeq :: DQ d iv v -> DQ d iv v -> Bool Source #

pOrdEq :: DQ d iv v -> DQ d iv v -> Bool Source #

pOrdMin :: [DQ d iv v] -> Maybe (DQ d iv v) Source #

pOrdMax :: [DQ d iv v] -> Maybe (DQ d iv v) Source #

pOrdReduceMin :: [DQ d iv v] -> [DQ d iv v] Source #

pOrdReduceMax :: [DQ d iv v] -> [DQ d iv v] Source #

Updatable (DQ d iv v) d iv Source #

For on-the fly updates of outputs

Methods

update :: UpdateData d iv -> DQ d iv v -> DQ d iv v Source #

Getters

isEmptyQ :: (Num d, Eq d) => QList d iv v -> Bool Source #

True when empty

getAtomsQ :: (Num d, Eq d) => QList d iv v -> [Atom d iv v] Source #

gets atoms at date zero (may unfold recursive definition)

atomsQ :: (Num d, Eq d) => QList d iv v -> QList d iv v Source #

keeps atoms at date zero dropping everything else

delayToTailQ :: (Num d, Eq d) => QList d iv v -> d Source #

gets delay to next atoms

tailQ :: (Num d, Eq d) => QList d iv v -> QList d iv v Source #

gets remainder of the qlist

q == QList (getAtomsQ q) (DQ (delayToTailQ q) (tailQ q))

getAllFromAtomsQ :: (Num d, Eq d) => QList d iv v -> [(d, v)] Source #

gets contents of atoms at date zero

dropAtomsQ :: (Num d, Eq d) => QList d iv v -> QList d iv v Source #

drops atoms at date zero

dropAtomsQ q == QList [] (DQ (delayToTailQ q) (tailQ q))

Setters

Primitive setters

fromValueQ :: Tilable d v => v -> QList d iv v Source #

Builds qlist from a tilable value (see Tile.Tilable)

fromDurationAndValueQ :: Num d => d -> v -> QList d iv v Source #

Builds qlist from a duration and a value

Append atoms or delay

appendQ :: (Num d, Lattice d) => [Atom d iv v] -> QList d iv v -> QList d iv v Source #

Appends a list of atoms to a q list

addDelayQ :: (Num d, POrd d) => d -> QList d iv v -> QList d iv v Source #

Delays a qlist by d unit of time (d must be positive)

Merge and delay

mergeDQ :: (Num d, Lattice d) => (DQ d iv v, DQ d iv v) -> DQ d iv v Source #

Merges two delayed qlists

mergeQ :: (Num d, Lattice d) => (QList d iv v, QList d iv v) -> QList d iv v Source #

Merges two qlists. This function relates with operation over tiles as follows:

Tile 0 0 (mergeQ q1 q2) = Tile 0 0 q1 + Tile 0 0 q2

insertQ :: (Num d, Lattice d) => QList d iv v -> DQ d iv v -> QList d iv v Source #

Merges a qlist and a delayed qlist into a qlist.

Stretch

stretchQ :: Num d => d -> QList d iv v -> QList d iv v Source #

Stretchs qlist by a given factor. This function relates with operation over tiles as follows:

Tile 0 0 (stretchQ d q) = fromDurationT d * Tile 0 0 q

stretchDQ :: Num d => d -> DQ d iv v -> DQ d iv v Source #

Stretchs dqlist by a given factor

Reduce

reduceQ :: (Num d, POrd d) => QList d iv v -> QList d iv v Source #

Reduces the head of a qlist by gluing all atom lists at zero delay from "now". This function may unfold immediate recursive definitions. The resulting 'head reduced qlist' is of any of one the following form:

QEnd (the empty list)
or QList al (DQ 0 QEnd) with non empty al (the non empty list of atoms)
or QList al (DQ d q) with stricly positive d

Functor like functions

fmapQ :: Num d => (v1 -> v2) -> QList d iv v1 -> QList d iv v2 Source #

Applies a function over values. This function relates with operation over tiles as follows:

Tile 0 0 (fmapQ f q) = fmap f (Tile 0 0 q)

fmapDQ :: Num d => (d -> d) -> QList d iv v -> QList d iv v Source #

Changes duration (same type).

Projections

Category based projection (Either acts as a categorical product)

fromLeftQ :: QList d iv (Either v1 v2) -> QList d iv v1 Source #

Gets from Left

fromRightQ :: QList d iv (Either v1 v2) -> QList d iv v2 Source #

Gets from Right

Duration based projections

takeQ :: (Num d, Lattice d) => d -> QList d iv v -> QList d iv v Source #

Keeps all atoms starting stricly before some duration d measured from the begining of the qlist and cut the qlist accordingly.

dropQ :: (Num d, Lattice d) => d -> QList d iv v -> QList d iv v Source #

Drops all atoms starting stricly before some duration d measured from the begining of the qlist and cut the qlist accordingly.

split :: Functor f => (b -> Bool) -> f b -> f (Either b b) Source #

Splits a qlist with a boolean function

Reverse

reverseQ :: (Num d, Lattice d) => d -> QList d iv v -> (d, QList d iv v) Source #

Returns the time symetric of a qlist, with symmetric point a fixed distance from its begining, and the distance from the beggining of that new list to the same fixed point.

qlistToTimedList :: Num d => d -> QList d iv v -> [(d, Atom d iv v)] Source #

Transforms a qlist into a list of pairs (d,Atom d iv v) where d marks the distance from the beggining of each atoms to a fixed zero in time

reverseTimedList :: Num d => [(d, Atom d iv v)] -> [(d, Atom d iv v)] Source #

Reverses timed lists, now taking distance from ends of atoms to the zero point.

timedListToQList :: (Num d, Lattice d) => [(d, Atom d iv v)] -> (d, QList d iv v) Source #

Transform a timed list into a qlist keeping the distance of the begining of the first atom to the zero

Other functions

unfoldQ :: Num d => QList d iv v -> QList d iv v Source #

Unfold all recursive definitions in a qlist (for debug purpose)

copyAndReplayQ :: (Num d, Lattice d) => d -> (QList d iv v -> QList d iv v) -> QList d iv v -> QList d iv v Source #

Some functions over qlists