forsyde-atom-0.3.0.0: Shallow-embedded DSL for modeling cyber-physical systems
Copyright(c) George Ungureanu 2015-2016
LicenseBSD-style (see the file LICENSE)
Maintainerugeorge@kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

ForSyDe.Atom.MoC.Stream

Description

This module defines the shallow-embedded Stream data type and utility functions operating on it. In ForSyDe a signal is represented as a (partially or totally) ordered sequence of events that enables processes to communicate and synchronize. In ForSyDe-Atom signals are the main operating type for the MoC layer. The Stream type is only the base (potentially infinite) structure which can encapsulate events in order to describe signals.

Synopsis

Documentation

data Stream e Source #

Defines a stream of events, encapsulating them in a structure isomorphic to an infinite list [Bird87], thus all properties of lists may also be applied to Streams. While, in combination with lazy evaluation, it is possible to create and simulate infinite signals, we need to ensure that the first/previous event is always fully evaluated, which is equivalent to ensuring the the monotonicity property in dataflow systems. This translates in the following composition rule:

non-causal feedback is forbidden
also called "zero-delay" feedback loops, are caused by un-evaluated self-referential calls. In a feedback loop, there always has to be enough events to ensure the data flow.

This rule imposes that the stream of data is uninterrupted in order to have an evaluatable kernel every time a new event is produced (i.e. to avoid deadlocks), which is ther equivalent to ensuring continuity in dataflow systems. This translates in the following rule:

cleaning of signals in a feedback is forbidden
in other words, whenever a feedback composition occurs, for each new input at any instant in time, a process must react with at least one output event.

Constructors

NullS

terminates a signal

e :- (Stream e) infixr 3

the default constructor appends an event to the head of the stream

Instances

Instances details
Functor Stream Source #

allows for the mapping of an arbitrary function (a -> b) upon all the events of a (Stream a).

Instance details

Defined in ForSyDe.Atom.MoC.Stream

Methods

fmap :: (a -> b) -> Stream a -> Stream b #

(<$) :: a -> Stream b -> Stream a #

Applicative Stream Source #

enables the Stream to behave like a ZipList

Instance details

Defined in ForSyDe.Atom.MoC.Stream

Methods

pure :: a -> Stream a #

(<*>) :: Stream (a -> b) -> Stream a -> Stream b #

liftA2 :: (a -> b -> c) -> Stream a -> Stream b -> Stream c #

(*>) :: Stream a -> Stream b -> Stream b #

(<*) :: Stream a -> Stream b -> Stream a #

Foldable Stream Source #

provides folding functions useful for implementing utilities, such as length.

Instance details

Defined in ForSyDe.Atom.MoC.Stream

Methods

fold :: Monoid m => Stream m -> m #

foldMap :: Monoid m => (a -> m) -> Stream a -> m #

foldMap' :: Monoid m => (a -> m) -> Stream a -> m #

foldr :: (a -> b -> b) -> b -> Stream a -> b #

foldr' :: (a -> b -> b) -> b -> Stream a -> b #

foldl :: (b -> a -> b) -> b -> Stream a -> b #

foldl' :: (b -> a -> b) -> b -> Stream a -> b #

foldr1 :: (a -> a -> a) -> Stream a -> a #

foldl1 :: (a -> a -> a) -> Stream a -> a #

toList :: Stream a -> [a] #

null :: Stream a -> Bool #

length :: Stream a -> Int #

elem :: Eq a => a -> Stream a -> Bool #

maximum :: Ord a => Stream a -> a #

minimum :: Ord a => Stream a -> a #

sum :: Num a => Stream a -> a #

product :: Num a => Stream a -> a #

Read a => Read (Stream a) Source #

signal (1 :- 2 :- NullS) is read using the string "{1,2}".

Instance details

Defined in ForSyDe.Atom.MoC.Stream

Show a => Show (Stream a) Source #

signal (1 :- 2 :- NullS) is represented as {1,2}.

Instance details

Defined in ForSyDe.Atom.MoC.Stream

Methods

showsPrec :: Int -> Stream a -> ShowS #

show :: Stream a -> String #

showList :: [Stream a] -> ShowS #

Plottable a => Plot (Signal a) Source #

SY signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Signal a) Source #

For plotting SDF signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

Plottable a => Plot (Signal a) Source #

For plotting CT signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

(Plottable a, Show t, Real t, Fractional t, Num t, Ord t, Eq t) => Plot (SignalBase t a) Source #

For plotting RE signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

(Plottable a, Show t, Real t, Fractional t, Num t, Ord t, Eq t) => Plot (SignalBase t a) Source #

For plotting DE signals.

Instance details

Defined in ForSyDe.Atom.Utility.Plot

stream :: [a] -> Stream a Source #

The function stream converts a list into a stream.

fromStream :: Stream a -> [a] Source #

The function fromStream converts a signal into a list.

headS :: Stream a -> a Source #

Returns the head of a signal.

tailS :: Stream e -> Stream e Source #

Returns the tail of a signal

lastS :: Stream p -> p Source #

Returns the last event in a signal.

repeatS :: a -> Stream a Source #

Returns an infinite list containing the same repeated event.

takeS :: (Num t, Ord t) => t -> Stream e -> Stream e Source #

Returns the first n events in a signal.

dropS :: (Num t, Ord t) => t -> Stream e -> Stream e Source #

Drops the first n events in a signal.

takeWhileS :: (a -> Bool) -> Stream a -> Stream a Source #

Returns the first events of a signal which comply to a condition.

(+-+) :: Stream e -> Stream e -> Stream e Source #

Concatenates two signals.