Copyright | (c) David Janin, Simon Archipoff, 2016 |
---|---|
License | see the LICENSE file in the distribution |
Maintainer | janin@labri.fr |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
QList
s are timed sequences of bundles of temporal values, that is,
lists of Atom
s synchronized on their starts, separated by (positive) delays.
QList
s are in one to one correspondance with zero duration tiles with no anticipation.
QList
s 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
- data QList d iv v where
- size_qlist :: QList t t1 t2 -> Int
- width_qlist :: QList t t1 t2 -> Int
- data DQ d iv v = DQ d (QList d iv v)
- isEmptyQ :: (Num d, Eq d) => QList d iv v -> Bool
- getAtomsQ :: (Num d, Eq d) => QList d iv v -> [Atom d iv v]
- atomsQ :: (Num d, Eq d) => QList d iv v -> QList d iv v
- delayToTailQ :: (Num d, Eq d) => QList d iv v -> d
- tailQ :: (Num d, Eq d) => QList d iv v -> QList d iv v
- getAllFromAtomsQ :: (Num d, Eq d) => QList d iv v -> [(d, v)]
- dropAtomsQ :: (Num d, Eq d) => QList d iv v -> QList d iv v
- fromValueQ :: Tilable d v => v -> QList d iv v
- fromDurationAndValueQ :: Num d => d -> v -> QList d iv v
- appendQ :: (Num d, Lattice d) => [Atom d iv v] -> QList d iv v -> QList d iv v
- addDelayQ :: (Num d, POrd d) => d -> QList d iv v -> QList d iv v
- mergeDQ :: (Num d, Lattice d) => (DQ d iv v, DQ d iv v) -> DQ d iv v
- mergeQ :: (Num d, Lattice d) => (QList d iv v, QList d iv v) -> QList d iv v
- insertQ :: (Num d, Lattice d) => QList d iv v -> DQ d iv v -> QList d iv v
- stretchQ :: Num d => d -> QList d iv v -> QList d iv v
- stretchDQ :: Num d => d -> DQ d iv v -> DQ d iv v
- reduceQ :: (Num d, POrd d) => QList d iv v -> QList d iv v
- fmapQ :: Num d => (v1 -> v2) -> QList d iv v1 -> QList d iv v2
- fmapDQ :: Num d => (d -> d) -> QList d iv v -> QList d iv v
- fromLeftQ :: QList d iv (Either v1 v2) -> QList d iv v1
- fromRightQ :: QList d iv (Either v1 v2) -> QList d iv v2
- takeQ :: (Num d, Lattice d) => d -> QList d iv v -> QList d iv v
- dropQ :: (Num d, Lattice d) => d -> QList d iv v -> QList d iv v
- split :: Functor f => (b -> Bool) -> f b -> f (Either b b)
- reverseQ :: (Num d, Lattice d) => d -> QList d iv v -> (d, QList d iv v)
- qlistToTimedList :: Num d => d -> QList d iv v -> [(d, Atom d iv v)]
- reverseTimedList :: Num d => [(d, Atom d iv v)] -> [(d, Atom d iv v)]
- timedListToQList :: (Num d, Lattice d) => [(d, Atom d iv v)] -> (d, QList d iv v)
- unfoldQ :: Num d => QList d iv v -> QList d iv v
- copyAndReplayQ :: (Num d, Lattice d) => d -> (QList d iv v -> QList d iv v) -> QList d iv v -> QList d iv v
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
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 |
Num d => Functor (QList d iv) Source # | |
(Num d, Eq d, POrd d, POrd v) => Eq (QList d iv v) Source # | Semantical equality, possibly unfolding recursive definitions. |
(Show d, Num d, Show v) => Show (QList d iv v) Source # | Show instance |
(Num d, Eq d, POrd d, POrd v) => POrd (QList d iv v) Source # | Derived |
Updatable (QList d iv v) d iv Source # | For on-the fly updates of outputs |
size_qlist :: QList t t1 t2 -> Int Source #
width_qlist :: QList t t1 t2 -> Int 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
Getters
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
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
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)
Projections
Category based projection (Either acts as a categorical product)
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