- Operators and functions
- Boolean constants
- Arithmetic operators (derived)
- Division
- Copilot variable declarations.
- Copilot constant declarations. For the most part, these are
- Boolean stream constants
- Constructs of the copilot language
- The next functions help typing the send operations
- Triggers
- Safe casting
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
or opsF2
opsF3
- mod :: (Streamable a, IntegralE a) => Spec a -> Spec a -> Spec a
- div :: (Streamable a, IntegralE a) => Spec a -> Spec a -> Spec a
- mod0 :: (Streamable a, IntegralE a) => a -> Spec a -> Spec a -> Spec a
- div0 :: (Streamable a, IntegralE a) => a -> Spec a -> Spec a -> Spec a
- (<) :: (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
- not :: Spec Bool -> Spec Bool
- (||) :: Spec Bool -> Spec Bool -> Spec Bool
- (&&) :: Spec Bool -> Spec Bool -> Spec Bool
- (^) :: Spec Bool -> Spec Bool -> Spec Bool
- (==>) :: Spec Bool -> Spec Bool -> Spec Bool
- data Bool
- class (Eq a, Show a) => Num a where
- class Num a => Fractional a where
- (/) :: a -> a -> a
- mux :: Streamable a => Spec Bool -> Spec a -> Spec a -> Spec a
- var :: Streamable a => Var -> Spec a
- varB :: Var -> Spec Bool
- varI8 :: Var -> Spec Int8
- varI16 :: Var -> Spec Int16
- varI32 :: Var -> Spec Int32
- varI64 :: Var -> Spec Int64
- varW8 :: Var -> Spec Word8
- varW16 :: Var -> Spec Word16
- varW32 :: Var -> Spec Word32
- varW64 :: Var -> Spec Word64
- varF :: Var -> Spec Float
- varD :: Var -> Spec Double
- const :: Streamable a => a -> Spec a
- constI8 :: Int8 -> Spec Int8
- constI16 :: Int16 -> Spec Int16
- constI32 :: Int32 -> Spec Int32
- constI64 :: Int64 -> Spec Int64
- constW8 :: Word8 -> Spec Word8
- constW16 :: Word16 -> Spec Word16
- constW32 :: Word32 -> Spec Word32
- constW64 :: Word64 -> Spec Word64
- constF :: Float -> Spec Float
- constD :: Double -> Spec Double
- true :: Spec Bool
- false :: Spec Bool
- module Language.Copilot.Language.Sampling
- drop :: Streamable a => Int -> Spec a -> Spec a
- (++) :: Streamable a => [a] -> Spec a -> Spec a
- (.=) :: Streamable a => Spec a -> Spec a -> Streams
- send :: Streamable a => String -> Port -> Spec a -> Streams
- port :: Int -> Port
- module Language.Copilot.Language.FunctionCalls
- module Language.Copilot.Language.Casting
- notConstVarErr :: Streamable a => Spec a -> (ArgConstVar -> b) -> b
Operators and functions
div :: (Streamable a, IntegralE a) => Spec a -> Spec a -> Spec aSource
Beware : crash without any possible recovery if a division by 0 happens. Same risk with mod. Use div0 and mod0 if unsure.
div0 :: (Streamable a, IntegralE a) => a -> Spec a -> Spec a -> Spec aSource
As mod and div, except that if the division would be by 0, the first argument is used as a default.
Boolean constants
data Bool
Arithmetic operators (derived)
class (Eq a, Show a) => Num a where
Basic numeric class.
Minimal complete definition: all except negate
or (-)
(+) :: 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
Division
class Num a => Fractional a where
Fractional numbers, supporting real division.
Minimal complete definition: fromRational
and (recip
or (
)
/
)
(/) :: a -> a -> a
fractional division
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 aSource
Beware : both sides are executed, even if the result of one is later discarded
Copilot variable declarations.
var :: Streamable a => Var -> Spec aSource
Useful for writing libraries.
Copilot constant declarations. For the most part, these are
const :: Streamable a => a -> Spec aSource
Coerces a type that is Streamable
into a Copilot constant.
Boolean stream constants
Constructs of the copilot language
(++) :: Streamable a => [a] -> Spec a -> Spec aSource
Just a trivial wrapper over the
constructor
Append
The next functions help typing the send operations
send :: Streamable a => String -> Port -> Spec a -> StreamsSource
Takes a function name
, a port number
, and a Copilot variable v
and
constructs a call to the C function name(x,y)
where x
is the value of the
Copilot stream v
and y
is the port number.
Triggers
Safe casting
notConstVarErr :: Streamable a => Spec a -> (ArgConstVar -> b) -> bSource