3 \frametitle{Current state of mTask
}
5 \item Suits our needs as an EDSL
6 \item It all seems perfect
7 \item \ldots\pause{} but
\ldots
10 \item Compilation requires reprogramming
11 \item Entire system is created and fixed
19 \item New bytecode backend for mTask
20 \item Interpreter on client
21 \item Server in iTasks with integration
22 \item No taskserver generation, onetime programming
23 \item Dynamic task sending
27 \subsection{Extending mTask
}
28 \begin{frame
}[fragile
]
29 \frametitle{Adding a View
}
30 \begin{lstlisting
}[language=Clean
]
31 :: ByteCode a p = BC (RWS ()
[BC
] BCState ())
32 :: BC = BCNop | BCPush BCValue | ...
33 :: BCValue = E.e: BCValue e & mTaskType, TC e
34 :: BCShare =
{ sdsi :: Int, sdsval :: BCValue, sdsname :: String
}
35 :: BCState =
{ freshl :: Int, freshs :: Int, sdss ::
[BCShare
] }
37 instance ByteCode arith, boolExpr, ...
41 \begin{frame
}[fragile
]
42 \frametitle{Implementation
}
44 \item Writing instruction
46 \item Hand-crafted helpers
48 \begin{lstlisting
}[language=Clean
]
49 op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr
50 op2 (BC x) (BC y) bc = BC (x >>| y >>| tell
[bc
])
52 tell2 ::
[BC
] -> (ByteCode a p)
55 instance arith ByteCode where
56 lit x = tell2
[BCPush (BCValue x)
]
57 (+.) x y = op2 x y BCDiv
62 \begin{frame
}[fragile
]
63 \frametitle{Control flow
}
71 \begin{lstlisting
}[language=Clean
]
72 :: BC = ... | BCLab Int | ...
74 freshlabel = get >>=
\st=:
{freshl
}->put
{st & freshl=freshl+
1} >>| pure freshl
76 instance If ByteCode Stmt Stmt Stmt where If b t e = BCIfStmt b t e
78 BCIfStmt (BC b) (BC t) (BC e) = BC (
79 freshlabel >>=
\else->freshlabel >>=
\endif->
80 b >>| tell
[BCJmpF else
] >>|
81 t >>| tell
[BCJmp endif, BCLab else
] >>|
82 e >>| tell
[BCLab endif
]
87 \begin{frame
}[fragile
]
88 \frametitle{Assignment and SDSs
}
89 \begin{lstlisting
}[language=Clean
]
90 instance sds ByteCode where
91 sds f =
{main = BC (freshshare
92 >>=
\sdsi->pure
{BCShare|sdsname="",sdsi=sdsi,sdsval=BCValue
0}
93 >>=
\sds->pure (f (tell2
[BCSdsFetch sds
]))
94 >>= \(v In bdy)->modify (addSDS sds v)
95 >>| unBC (unMain bdy))
98 instance assign ByteCode where
99 (=.) (BC v) (BC e) = BC (e >>| censor makeStore v)
101 instance sdspub ByteCode where
102 pub (BC x) = BC (censor (\
[BCSdsFetch s
]->
[BCSdsPublish s
]) x)
104 makeStore
[BCSdsFetch i
] =
[BCSdsStore i
]
105 makeStore
[BCDigitalRead i
] =
[BCDigitalWrite i
]
106 makeStore
[...
] =
[...
]
110 \begin{frame
}[fragile
]
111 \frametitle{Bandwidth is scarce
}
112 Publish SDS explicitly
116 pub :: (v t Upd) -> (v () Stmt)
117 instance sdspub ByteCode where
118 pub (BC x) = BC (censor (\
[BCSdsFetch s
]->
[BCSdsPublish s
]) x)
122 \begin{frame
}[fragile
]
123 \frametitle{Task scheduling
}
127 \item Tasks start other tasks
133 \item Old system, taskserver, tasks start tasks
134 \item New system, task+strategy
138 \item \CI{OnInterval
}
139 \item \CI{OnInterrupt
}
142 \item How to handle termination
145 \begin{lstlisting
}[language=Clean
]
152 \subsection{Interpretation
}
153 \begin{frame
}[fragile
]
154 \frametitle{mTask implementation
}
163 \item Implement some classes in interface
165 \item How to handle termination
170 \begin{frame
}[fragile
]
172 \framesubtitle{Parametric Lenses
}
173 \begin{block
}{What is the
\CI{p
} for in
\CI{RWShared p r w
}}
176 \item Parameter fixed when writing
177 \item Used for notifications
178 \item On write the SDS returns
\CI{p -> Bool
}
183 %sdsFocus :: p1 (RWShared p1 r w) -> RWShared p2 r w | iTask p
185 %:: SDSNotifyPred p :== p -> Bool
186 %:: SDSLensRead p r rs = SDSRead (p -> rs -> MaybeError TaskException r)
187 % | SDSReadConst (p -> r)
188 %:: SDSLensWrite p w rs ws = SDSWrite (p -> rs -> w -> MaybeError TaskException (Maybe ws))
189 % | SDSWriteConst (p -> w -> MaybeError TaskException (Maybe ws))
190 %:: SDSLensNotify p w rs = SDSNotify (p -> rs -> w -> SDSNotifyPred p)
191 % | SDSNotifyConst (p -> w -> SDSNotifyPred p)
193 %sdsLens :: String (p -> ps) (SDSLensRead p r rs) (SDSLensWrite p w rs ws)
194 % (SDSLensNotify p w rs) (RWShared ps rs ws) -> RWShared p r w | iTask ps
197 \subsection{Examples
}