In contrast to deep embedding, it is very well possible to have multiple views
applied on the same expression. This is also shown in the following listing.
-\begin{lstlisting}[label={lst:exclassshallow},%
+\begin{lstlisting}[language=Clean,label={lst:exclassshallow},%
caption={A minimal class based shallow \gls{EDSL}}]
:: Env = ... // Some environment
:: Evaluator a = Evaluator (Env -> a)
eq :: (v t) (v t) -> (v Bool) | == t
instance intArith Evaluator where
- lit x = \e->x
- add x y = ...
+ lit x = Evaluator \e->x
+ add x y = Evaluator ...
instance intArith PrettyPrinter where
- lit x = toString x
- add x y = x +++ "+" +++ y
+ lit x = PP $ toString x
+ add x y = PP $ x +++ "+" +++ y
...
...