|
|
|
|
|
Description |
Provides basic types and functions for other parts of Copilot.
If you wish to add a new type, you need to make it an instance of Streamable,
to add it to foldStreamableMaps, mapStreamableMaps, and optionnaly
to add an ext[Type], a [type] and a var[Type]
functions in Language.hs to make it easier to use.
|
|
Synopsis |
|
|
|
|
Type hierarchy for the copilot language
|
|
type Var = String |
Names of the streams or external variables
|
|
type Name = String |
C file name
|
|
type Period = Int |
Atom period
|
|
type Phase = Int |
Phase of an Atom phase
|
|
type Port = Int |
Port over which to broadcast information
|
|
data Spec a where |
Specification of a stream, parameterized by the type of the values of the stream.
The only requirement on a is that it should be Streamable.
| Constructors | | Instances | |
|
|
type Streams = Writer (StreamableMaps Spec) () |
Container for mutually recursive streams, whose specifications may be
parameterized by different types
type Streams = StreamableMaps Spec
|
|
type Stream a = Streamable a => (Var, Spec a) |
A named stream
|
|
type Sends = StreamableMaps Send |
Container for all the instructions sending data, parameterised by different types
|
|
data Send a |
An instruction to send data on a port at a given phase
| Constructors | |
|
|
type DistributedStreams = (Streams, Sends) |
Holds the complete specification of a distributed monitor
|
|
General functions on Streams and StreamableMaps
|
|
class (Expr a, Assign a, Show a) => Streamable a where |
A type is streamable iff a stream may emit values of that type
There are very strong links between Streamable and StreamableMaps :
the types aggregated in StreamableMaps are exactly the Streamable types
and that invariant should be kept (see methods)
| | Methods | getSubMap :: StreamableMaps b -> Map Var (b a) | Provides access to the Map in a StreamableMaps which store values
of the good type
| | updateSubMap :: (Map Var (b a) -> Map Var (b a)) -> StreamableMaps b -> StreamableMaps b | Provides a way to modify (mostly used for insertions) the Map in a StreamableMaps
which store values of the good type
| | unit :: a | A default value for the type a. Its value is not important.
| | atomConstructor :: Var -> a -> Atom (V a) | A constructor to produce an Atom value
| | externalAtomConstructor :: Var -> V a | A constructor to get an Atom value from an external variable
| | typeId :: a -> String | The argument only coerces the type, it is discarded.
Returns the format for outputting a value of this type with printf in C
For example %f for a float
| | typeIdPrec :: a -> String | The same, only adds the wanted precision for floating points.
| | atomType :: a -> Type | The argument only coerces the type, it is discarded.
Returns the corresponding Atom type.
| | showAsC :: a -> String | Like Show, except that the formatting is exactly the same as the one of C
for example the booleans are first converted to 0 or 1, and floats and doubles
have the good precision.
| | makeTrigger :: Maybe [(Var, String)] -> StreamableMaps Spec -> ProphArrs -> TmpSamples -> Indexes -> Var -> Spec a -> Atom () -> Atom () | To make customer C triggers. Only for Spec Bool (others through an error).
|
| | Instances | |
|
|
class Streamable a => Sendable a where |
| Methods | send :: E a -> Port -> Atom () |
| | Instances | |
|
|
data StreamableMaps a |
This is a generalization of Streams
which is used for storing Maps over values parameterized by different types.
It is extensively used in the internals of Copilot, in conjunction with
foldStreamableMaps and mapStreamableMaps
| Constructors | | Instances | (Show (a Bool), Show (a Int8), Show (a Int16), Show (a Int32), Show (a Int64), Show (a Word8), Show (a Word16), Show (a Word32), Show (a Word64), Show (a Float), Show (a Double)) => Show (StreamableMaps a) | Monoid (StreamableMaps Spec) |
|
|
|
emptySM :: StreamableMaps a |
An empty streamableMaps.
|
|
isEmptySM :: StreamableMaps a -> Bool |
Verifies if its argument is equal to emptySM
|
|
getMaybeElem :: Streamable a => Var -> StreamableMaps b -> Maybe (b a) |
Lookup into the map of the right type in StreamableMaps
|
|
getElem :: Streamable a => Var -> StreamableMaps b -> b a |
Lookup into the map of the right type in StreamableMaps
Launch an exception if the index is not in it
|
|
streamToUnitValue :: Streamable a => Var -> Spec a -> Atom (V a) |
Just produce an Atom value named after its first argument,
with an unspecified value. The second argument only coerces the type, it is discarded
|
|
foldStreamableMaps :: forall b c. (forall a. Streamable a => Var -> c a -> b -> b) -> StreamableMaps c -> b -> b |
This function is used to iterate on all the values in all the maps stored
by a StreamableMaps, accumulating a value over time
|
|
foldSendableMaps :: forall b c. (forall a. Sendable a => Var -> c a -> b -> b) -> StreamableMaps c -> b -> b |
This function is used to iterate on all the values in all the maps stored
by a StreamableMaps, accumulating a value over time
|
|
mapStreamableMaps :: forall s s'. (forall a. Streamable a => Var -> s a -> s' a) -> StreamableMaps s -> StreamableMaps s' |
|
mapStreamableMapsM :: forall s s' m. Monad m => (forall a. Streamable a => Var -> s a -> m (s' a)) -> StreamableMaps s -> m (StreamableMaps s') |
|
filterStreamableMaps :: forall c. StreamableMaps c -> [(Type, Var, Phase)] -> (StreamableMaps c, Bool) |
Only keeps in sm the values whose key+type are in l.
Also returns a bool saying whether all the elements in sm
were in l.
Works even if some elements in l are not in sm.
Not optimised at all
|
|
normalizeVar :: Var -> Var |
Replace all accepted special characters by sequences of underscores
|
|
getVars :: StreamableMaps Spec -> [Var] |
Get the Copilot variables.
|
|
type Vars = StreamableMaps [] |
For each typed variable, this type holds all its successive values in an infinite list
Beware : each element of one of those lists corresponds to a full Atom period,
not to a single clock tick.
|
|
nextSt :: Streamable a => StreamableMaps Spec -> ProphArrs -> TmpSamples -> Indexes -> Spec a -> ArrIndex -> E a |
|
data BoundedArray a |
|
|
type Outputs = StreamableMaps V |
|
type TmpSamples = StreamableMaps PhasedValue |
|
data PhasedValue a |
|
|
type ProphArrs = StreamableMaps BoundedArray |
|
type Indexes = Map Var (V ArrIndex) |
|
Produced by Haddock version 2.6.1 |