atom-1.0.7: A DSL for embedded hard realtime applications.ContentsIndex
Language.Atom.Expressions
Contents
Types
Constants
Variable Reference and Assignment
Logical Operations
Equality and Comparison
Arithmetic Operations
Conditional Operator
Array Indexing
Smart constructors for untyped expressions.
Synopsis
data E a where
VRef :: V a -> E a
Const :: a -> E a
Cast :: (NumE a, NumE b) => E a -> E b
Add :: NumE a => E a -> E a -> E a
Sub :: NumE a => E a -> E a -> E a
Mul :: NumE a => E a -> E a -> E a
Div :: NumE a => E a -> E a -> E a
Mod :: IntegralE a => E a -> E a -> E a
Not :: E Bool -> E Bool
And :: E Bool -> E Bool -> E Bool
BWNot :: IntegralE a => E a -> E a
BWAnd :: IntegralE a => E a -> E a -> E a
BWOr :: IntegralE a => E a -> E a -> E a
Shift :: IntegralE a => E a -> Int -> E a
Eq :: EqE a => E a -> E a -> E Bool
Lt :: OrdE a => E a -> E a -> E Bool
Mux :: E Bool -> E a -> E a -> E a
F2B :: E Float -> E Word32
D2B :: E Double -> E Word64
B2F :: E Word32 -> E Float
B2D :: E Word64 -> E Double
Retype :: UE -> E a
Pi :: FloatingE a => E a
Exp :: FloatingE a => E a -> E a
Log :: FloatingE a => E a -> E a
Sqrt :: FloatingE a => E a -> E a
Pow :: FloatingE a => E a -> E a -> E a
Sin :: FloatingE a => E a -> E a
Asin :: FloatingE a => E a -> E a
Cos :: FloatingE a => E a -> E a
Acos :: FloatingE a => E a -> E a
Sinh :: FloatingE a => E a -> E a
Cosh :: FloatingE a => E a -> E a
Asinh :: FloatingE a => E a -> E a
Acosh :: FloatingE a => E a -> E a
Atan :: FloatingE a => E a -> E a
Atanh :: FloatingE a => E a -> E a
data V a = V UV
data UE
= UVRef UV
| UConst Const
| UCast Type UE
| UAdd UE UE
| USub UE UE
| UMul UE UE
| UDiv UE UE
| UMod UE UE
| UNot UE
| UAnd [UE]
| UBWNot UE
| UBWAnd UE UE
| UBWOr UE UE
| UShift UE Int
| UEq UE UE
| ULt UE UE
| UMux UE UE UE
| UF2B UE
| UD2B UE
| UB2F UE
| UB2D UE
| UPi
| UExp UE
| ULog UE
| USqrt UE
| UPow UE UE
| USin UE
| UAsin UE
| UCos UE
| UAcos UE
| USinh UE
| UCosh UE
| UAsinh UE
| UAcosh UE
| UAtan UE
| UAtanh UE
data UV
= UV Int String Const
| UVArray UA UE
| UVExtern String Type
data A a = A UA
data UA
= UA Int String [Const]
| UAExtern String Type
class Eq a => Expr a where
eType :: E a -> Type
constant :: a -> Const
expression :: E a -> Expression
variable :: V a -> Variable
rawBits :: E a -> E Word64
data Expression
= EBool (E Bool)
| EInt8 (E Int8)
| EInt16 (E Int16)
| EInt32 (E Int32)
| EInt64 (E Int64)
| EWord8 (E Word8)
| EWord16 (E Word16)
| EWord32 (E Word32)
| EWord64 (E Word64)
| EFloat (E Float)
| EDouble (E Double)
data Variable
= VBool (V Bool)
| VInt8 (V Int8)
| VInt16 (V Int16)
| VInt32 (V Int32)
| VInt64 (V Int64)
| VWord8 (V Word8)
| VWord16 (V Word16)
| VWord32 (V Word32)
| VWord64 (V Word64)
| VFloat (V Float)
| VDouble (V Double)
data Type
= Bool
| Int8
| Int16
| Int32
| Int64
| Word8
| Word16
| Word32
| Word64
| Float
| Double
data Const
= CBool Bool
| CInt8 Int8
| CInt16 Int16
| CInt32 Int32
| CInt64 Int64
| CWord8 Word8
| CWord16 Word16
| CWord32 Word32
| CWord64 Word64
| CFloat Float
| CDouble Double
class Width a where
width :: a -> Int
class TypeOf a where
typeOf :: a -> Type
bytes :: Width a => a -> Int
ue :: Expr a => E a -> UE
uv :: V a -> UV
ueUpstream :: UE -> [UE]
nearestUVs :: UE -> [UV]
arrayIndices :: UE -> [(UA, UE)]
class (Num a, Expr a, EqE a, OrdE a) => NumE a
class (NumE a, Integral a) => IntegralE a
class (RealFloat a, NumE a, OrdE a) => FloatingE a
class (Eq a, Expr a) => EqE a
class (Eq a, Ord a, EqE a) => OrdE a
true :: E Bool
false :: E Bool
value :: V a -> E a
not_ :: E Bool -> E Bool
(&&.) :: E Bool -> E Bool -> E Bool
(||.) :: E Bool -> E Bool -> E Bool
and_ :: [E Bool] -> E Bool
or_ :: [E Bool] -> E Bool
any_ :: (a -> E Bool) -> [a] -> E Bool
all_ :: (a -> E Bool) -> [a] -> E Bool
imply :: E Bool -> E Bool -> E Bool
(==.) :: EqE a => E a -> E a -> E Bool
(/=.) :: EqE a => E a -> E a -> E Bool
(<.) :: OrdE a => E a -> E a -> E Bool
(<=.) :: OrdE a => E a -> E a -> E Bool
(>.) :: OrdE a => E a -> E a -> E Bool
(>=.) :: OrdE a => E a -> E a -> E Bool
min_ :: OrdE a => E a -> E a -> E a
minimum_ :: OrdE a => [E a] -> E a
max_ :: OrdE a => E a -> E a -> E a
maximum_ :: OrdE a => [E a] -> E a
limit :: OrdE a => E a -> E a -> E a -> E a
div_ :: IntegralE a => E a -> E a -> E a
div0_ :: IntegralE a => E a -> E a -> a -> E a
mod_ :: IntegralE a => E a -> E a -> E a
mod0_ :: IntegralE a => E a -> E a -> a -> E a
mux :: Expr a => E Bool -> E a -> E a -> E a
(!) :: (Expr a, IntegralE b) => A a -> E b -> V a
(!.) :: (Expr a, IntegralE b) => A a -> E b -> E a
ubool :: Bool -> UE
unot :: UE -> UE
uand :: UE -> UE -> UE
uor :: UE -> UE -> UE
ueq :: UE -> UE -> UE
umux :: UE -> UE -> UE -> UE
Types
data E a where
A typed expression.
Constructors
VRef :: V a -> E a
Const :: a -> E a
Cast :: (NumE a, NumE b) => E a -> E b
Add :: NumE a => E a -> E a -> E a
Sub :: NumE a => E a -> E a -> E a
Mul :: NumE a => E a -> E a -> E a
Div :: NumE a => E a -> E a -> E a
Mod :: IntegralE a => E a -> E a -> E a
Not :: E Bool -> E Bool
And :: E Bool -> E Bool -> E Bool
BWNot :: IntegralE a => E a -> E a
BWAnd :: IntegralE a => E a -> E a -> E a
BWOr :: IntegralE a => E a -> E a -> E a
Shift :: IntegralE a => E a -> Int -> E a
Eq :: EqE a => E a -> E a -> E Bool
Lt :: OrdE a => E a -> E a -> E Bool
Mux :: E Bool -> E a -> E a -> E a
F2B :: E Float -> E Word32
D2B :: E Double -> E Word64
B2F :: E Word32 -> E Float
B2D :: E Word64 -> E Double
Retype :: UE -> E a
Pi :: FloatingE a => E a
Exp :: FloatingE a => E a -> E a
Log :: FloatingE a => E a -> E a
Sqrt :: FloatingE a => E a -> E a
Pow :: FloatingE a => E a -> E a -> E a
Sin :: FloatingE a => E a -> E a
Asin :: FloatingE a => E a -> E a
Cos :: FloatingE a => E a -> E a
Acos :: FloatingE a => E a -> E a
Sinh :: FloatingE a => E a -> E a
Cosh :: FloatingE a => E a -> E a
Asinh :: FloatingE a => E a -> E a
Acosh :: FloatingE a => E a -> E a
Atan :: FloatingE a => E a -> E a
Atanh :: FloatingE a => E a -> E a
show/hide Instances
Expr a => Eq (E a)
(Num a, Fractional a, Floating a, FloatingE a) => Floating (E a)
(OrdE a, NumE a, Num a, Fractional a) => Fractional (E a)
(Num a, NumE a, OrdE a) => Num (E a)
Show (E a)
(Expr a, OrdE a, EqE a, IntegralE a, Bits a) => Bits (E a)
Expr a => TypeOf (E a)
Expr a => Width (E a)
data V a
Variables updated by state transition rules.
Constructors
V UV
show/hide Instances
Eq (V a)
TypeOf (V a)
Expr a => Width (V a)
data UE
An untyped term.
Constructors
UVRef UV
UConst Const
UCast Type UE
UAdd UE UE
USub UE UE
UMul UE UE
UDiv UE UE
UMod UE UE
UNot UE
UAnd [UE]
UBWNot UE
UBWAnd UE UE
UBWOr UE UE
UShift UE Int
UEq UE UE
ULt UE UE
UMux UE UE UE
UF2B UE
UD2B UE
UB2F UE
UB2D UE
UPi
UExp UE
ULog UE
USqrt UE
UPow UE UE
USin UE
UAsin UE
UCos UE
UAcos UE
USinh UE
UCosh UE
UAsinh UE
UAcosh UE
UAtan UE
UAtanh UE
show/hide Instances
data UV
Untyped variables.
Constructors
UV Int String Const
UVArray UA UE
UVExtern String Type
show/hide Instances
data A a
A typed array.
Constructors
A UA
show/hide Instances
Eq (A a)
TypeOf (A a)
data UA
An untyped array.
Constructors
UA Int String [Const]
UAExtern String Type
show/hide Instances
class Eq a => Expr a where
Methods
eType :: E a -> Type
constant :: a -> Const
expression :: E a -> Expression
variable :: V a -> Variable
rawBits :: E a -> E Word64
show/hide Instances
data Expression
Constructors
EBool (E Bool)
EInt8 (E Int8)
EInt16 (E Int16)
EInt32 (E Int32)
EInt64 (E Int64)
EWord8 (E Word8)
EWord16 (E Word16)
EWord32 (E Word32)
EWord64 (E Word64)
EFloat (E Float)
EDouble (E Double)
data Variable
Constructors
VBool (V Bool)
VInt8 (V Int8)
VInt16 (V Int16)
VInt32 (V Int32)
VInt64 (V Int64)
VWord8 (V Word8)
VWord16 (V Word16)
VWord32 (V Word32)
VWord64 (V Word64)
VFloat (V Float)
VDouble (V Double)
show/hide Instances
data Type
The type of a E.
Constructors
Bool
Int8
Int16
Int32
Int64
Word8
Word16
Word32
Word64
Float
Double
show/hide Instances
data Const
Constructors
CBool Bool
CInt8 Int8
CInt16 Int16
CInt32 Int32
CInt64 Int64
CWord8 Word8
CWord16 Word16
CWord32 Word32
CWord64 Word64
CFloat Float
CDouble Double
show/hide Instances
class Width a where
Methods
width :: a -> Int
show/hide Instances
class TypeOf a where
Methods
typeOf :: a -> Type
show/hide Instances
bytes :: Width a => a -> Int
ue :: Expr a => E a -> UE
Converts an typed expression (E a) to an untyped expression (UE).
uv :: V a -> UV
ueUpstream :: UE -> [UE]
The list of UEs adjacent upstream of a UE.
nearestUVs :: UE -> [UV]
The list of all UVs that directly control the value of an expression.
arrayIndices :: UE -> [(UA, UE)]
All array indexing subexpressions.
class (Num a, Expr a, EqE a, OrdE a) => NumE a
show/hide Instances
class (NumE a, Integral a) => IntegralE a
show/hide Instances
class (RealFloat a, NumE a, OrdE a) => FloatingE a
show/hide Instances
class (Eq a, Expr a) => EqE a
show/hide Instances
class (Eq a, Ord a, EqE a) => OrdE a
show/hide Instances
Constants
true :: E Bool
True term.
false :: E Bool
False term.
Variable Reference and Assignment
value :: V a -> E a
Returns the value of a V.
Logical Operations
not_ :: E Bool -> E Bool
Logical negation.
(&&.) :: E Bool -> E Bool -> E Bool
Logical AND.
(||.) :: E Bool -> E Bool -> E Bool
Logical OR.
and_ :: [E Bool] -> E Bool
The conjunction of a E Bool list.
or_ :: [E Bool] -> E Bool
The disjunction of a E Bool list.
any_ :: (a -> E Bool) -> [a] -> E Bool
True iff the predicate is true for any element.
all_ :: (a -> E Bool) -> [a] -> E Bool
True iff the predicate is true for all elements.
imply :: E Bool -> E Bool -> E Bool
Equality and Comparison
(==.) :: EqE a => E a -> E a -> E Bool
Equal.
(/=.) :: EqE a => E a -> E a -> E Bool
Not equal.
(<.) :: OrdE a => E a -> E a -> E Bool
Less than.
(<=.) :: OrdE a => E a -> E a -> E Bool
Less than or equal.
(>.) :: OrdE a => E a -> E a -> E Bool
Greater than.
(>=.) :: OrdE a => E a -> E a -> E Bool
Greater than or equal.
min_ :: OrdE a => E a -> E a -> E a
Returns the minimum of two numbers.
minimum_ :: OrdE a => [E a] -> E a
Returns the minimum of a list of numbers.
max_ :: OrdE a => E a -> E a -> E a
Returns the maximum of two numbers.
maximum_ :: OrdE a => [E a] -> E a
Returns the maximum of a list of numbers.
limit :: OrdE a => E a -> E a -> E a -> E a
Limits between min and max.
Arithmetic Operations
div_ :: IntegralE a => E a -> E a -> E a
Division. If both the dividend and divisor are constants, a compile-time check is made for divide-by-zero. Otherwise, if the divisor ever evaluates to 0, a runtime exception will occur, even if the division occurs within the scope of a cond or mux that tests for 0 (because Atom generates deterministic-time code, every branch of a cond or mux is executed).
div0_ :: IntegralE a => E a -> E a -> a -> E a
Division, where the C code is instrumented with a runtime check to ensure the divisor does not equal 0. If it is equal to 0, the 3rd argument is a user-supplied non-zero divsor.
mod_ :: IntegralE a => E a -> E a -> E a
Modulo. If both the dividend and modulus are constants, a compile-time check is made for divide-by-zero. Otherwise, if the modulus ever evaluates to 0, a runtime exception will occur, even if the division occurs within the scope of a cond or mux that tests for 0 (because Atom generates deterministic-time code, every branch of a cond or mux is executed).
mod0_ :: IntegralE a => E a -> E a -> a -> E a
Modulus, where the C code is instrumented with a runtime check to ensure the modulus does not equal 0. If it is equal to 0, the 3rd argument is a user-supplied non-zero divsor.
Conditional Operator
mux :: Expr a => E Bool -> E a -> E a -> E a

Conditional expression. Note, both branches are evaluated!

 mux test onTrue onFalse
Array Indexing
(!) :: (Expr a, IntegralE b) => A a -> E b -> V a
Array index to variable.
(!.) :: (Expr a, IntegralE b) => A a -> E b -> E a
Array index to expression.
Smart constructors for untyped expressions.
ubool :: Bool -> UE
unot :: UE -> UE
uand :: UE -> UE -> UE
uor :: UE -> UE -> UE
ueq :: UE -> UE -> UE
umux :: UE -> UE -> UE -> UE
Produced by Haddock version 2.7.2