copilot-1.0.2: A stream DSL for writing embedded C monitors.

Language.Copilot.Language

Contents

Description

Describes the language Copilot.

If you wish to add a new operator, the only modification needed is adding it in this module. But if you want it to be used in the random generated streams, add it to either opsF, opsF2 or opsF3

Synopsis

Operators and functions

mod :: (Streamable a, IntegralE a) => Spec a -> Spec a -> Spec a

div :: (Streamable a, IntegralE a) => Spec a -> Spec a -> Spec a

Beware : crash without any possible recovery if a division by 0 happens. Same risk with mod. Use div0 and mod0 if unsure.

mod0 :: (Streamable a, IntegralE a) => a -> Spec a -> Spec a -> Spec a

div0 :: (Streamable a, IntegralE a) => a -> Spec a -> Spec a -> Spec a

As mod and div, except that if the division would be by 0, the first argument is used as a default.

(<) :: (Streamable a, OrdE a) => Spec a -> Spec a -> Spec Bool

(<=) :: (Streamable a, OrdE a) => Spec a -> Spec a -> Spec Bool

(==) :: (Streamable a, EqE a) => Spec a -> Spec a -> Spec Bool

(/=) :: (Streamable a, EqE a) => Spec a -> Spec a -> Spec Bool

(>=) :: (Streamable a, OrdE a) => Spec a -> Spec a -> Spec Bool

(>) :: (Streamable a, OrdE a) => Spec a -> Spec a -> Spec Bool

Boolean constants

data Bool

Constructors

False 
True 

Instances

Bounded Bool 
Enum Bool 
Eq Bool 
Ord Bool 
Show Bool 
Random Bool 
EqE Bool 
Expr Bool 
Assign Bool 
Streamable Bool 
Castable Bool 

Arithmetic operators (derived)

class (Eq a, Show a) => Num a where

Basic numeric class.

Minimal complete definition: all except negate or (-)

Methods

(+) :: a -> a -> a

(*) :: a -> a -> a

(-) :: a -> a -> a

negate :: a -> a

Unary negation.

abs :: a -> a

Absolute value.

signum :: a -> a

Sign of a number. The functions abs and signum should satisfy the law:

 abs x * signum x == x

For real numbers, the signum is either -1 (negative), 0 (zero) or 1 (positive).

fromInteger :: Integer -> a

Conversion from an Integer. An integer literal represents the application of the function fromInteger to the appropriate value of type Integer, so such literals have type (Num a) => a.

Instances

Num Double 
Num Float 
Num Int 
Num Int8 
Num Int16 
Num Int32 
Num Int64 
Num Integer 
Num Word 
Num Word8 
Num Word16 
Num Word32 
Num Word64 
Integral a => Num (Ratio a) 
(Num a, NumE a, OrdE a) => Num (E a) 
(Streamable a, NumE a) => Num (Spec a) 

Division

class Num a => Fractional a where

Fractional numbers, supporting real division.

Minimal complete definition: fromRational and (recip or (/))

Methods

(/) :: a -> a -> a

fractional division

Instances

Fractional Double 
Fractional Float 
Integral a => Fractional (Ratio a) 
(OrdE a, NumE a, Num a, Fractional a) => Fractional (E a) 
(Streamable a, NumE a, Fractional a) => Fractional (Spec a) 

mux :: Streamable a => Spec Bool -> Spec a -> Spec a -> Spec a

Beware : both sides are executed, even if the result of one is later discarded

Copilot variable declarations.

var :: Streamable a => Var -> Spec a

Useful for writing libraries.

Copilot constant declarations. For the most part, these are

const :: Streamable a => a -> Spec a

Coerces a type that is Streamable into a Copilot constant.

Boolean stream constants

Constructs of the copilot language

drop :: Streamable a => Int -> Spec a -> Spec a

Drop i elements from a stream.

(++) :: Streamable a => [a] -> Spec a -> Spec a

Just a trivial wrapper over the Append constructor

(.=) :: Streamable a => Spec a -> Spec a -> Streams

Define a stream variable.

Triggers

Safe casting

notConstVarErr :: Streamable a => Spec a -> (ArgConstVar -> b) -> b

If the Spec isn't a Var or Const, then throw an error; otherwise, apply the function.