3 \frametitle{Embedded Domain Specific Language
}
4 \framesubtitle{What is are EDSL
}
6 \item DSL:\ language for a specific domain
7 \item E.g., PostScript, VimScript, HTML,
\ldots
9 \item EDSL:\ Embedded DSL
10 \item Language in a language
11 \item Use the properties of the host
12 \item E.g., Ivory,
\ldots\pause{} and iTasks
16 \begin{frame
}[fragile
]
17 \frametitle{Deep embedding
}
19 \column{.49\textwidth}
20 \begin{block
}{What is deep embedding
}
22 \item The EDSL as an ADT
23 \item A view is a function transforming the ADT
26 \column{.49\textwidth}
29 :: DSL = LitI Int | LitB Bool
30 | Var String | Plus DSL DSL
31 | Minus DSL DSL | And DSL DSL
34 eval :: DSL Env -> Env
35 pprint :: DSL -> String
39 \begin{block
}{Properties
}
41 \item Easy to add views
49 \begin{frame
}[fragile
]
50 \frametitle{Shallow embedding
}
52 \column{.49\textwidth}
53 \begin{block
}{What is shallow embedding
}
55 \item The EDSL as a function
56 \item The view is embedded in the function
60 \column{.49\textwidth}
63 :: DSL a = DSL (Env -> a)
68 Var :: String -> DSL Int
69 Var i =
\e -> retrEnv e i
71 Plus :: (DSL Int) (DSL Int) -> DSL Int
72 Plus x y =
\e -> x e + y e
76 \begin{block
}{Properties
}
78 \item Difficult to add views
85 \begin{frame
}[fragile
]
86 \frametitle{Class based shallow embedding
}
88 \column{.49\textwidth}
90 \begin{block
}{The best of both worlds
}
92 \item The EDSL is a collection of classes
93 \item Views are types implementing a subset
98 \begin{block
}{Properties
}
102 \item Easy to add views
106 \column{.49\textwidth}
110 :: Evaluator a = Evaluator (Env -> a)
111 :: PrettyPrinter a = PP String
114 lit :: t -> v t | toString t
115 add :: (v t) (v t) -> (v t) | + t
116 minus :: (v t) (v t) -> (v t) | - t
118 class boolArith where ...
120 instance intArith Evaluator where
121 lit x = Evaluator
\e->x
122 add x y = Evaluator ...
125 instance intArith PrettyPrinter where
126 lit x = PP $ toString x
127 add x y = PP $ x +++ "+" +++ y
138 \begin{block
}{What is mTask
}
141 \item Arduino C++ generation, iTasks simulation
145 \begin{block
}{Considerations
}
148 \item Embedded in Clean
150 \item \ldots\pause{} but
\ldots
152 \item Compilation requires reprogramming