Merge branch 'master' of git.martlubbers.net:msc-thesis1617
[msc-thesis1617.git] / mtask.expr.tex
1 Expressions in the \gls{mTask}-\gls{EDSL} are divided into two types, namely
2 boolean expressions and arithmetic expressions. The class of arithmetic
3 language constructs also contains the function \CI{lit} that lifts a
4 host-language value into the \gls{EDSL} domain. All standard arithmetic
5 functions are included in the \gls{EDSL} but are omitted in the example for
6 brevity. Moreover, the class restrictions are only shown in the first functions
7 and are omitted in subsequent functions. Both the boolean expression and
8 arithmetic expression classes are shown in Listing~\ref{lst:arithbool}.
9
10 \begin{lstlisting}[language=Clean,label={lst:arithbool},
11 caption={Basic classes for expressions}]
12 class arith v where
13 lit :: t -> v t Expr
14 (+.) infixl 6 :: (v t p) (v t q) -> v t Expr | +, zero t & isExpr p & isExpr q
15 (-.) infixl 6 :: (v t p) (v t q) -> v t Expr | -, zero t & ...
16 ...
17 class boolExpr v where
18 Not :: (v Bool p) -> v Bool Expr | ...
19 (&.) infixr 3 :: (v Bool p) (v Bool q) -> v Bool Expr | ...
20 ...
21 (==.) infix 4 :: (v a p) (v a q) -> v Bool Expr | ==, toCode a & ...
22 \end{lstlisting}