\begin{lstlisting}[label={lst:connectDevice},%
caption={Connect a device}]
connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task Channels
-connectDevice procFun device = let ch = channels device
- in traceValue "connectDevice" >>| appendTopLevelTask 'DM'.newMap True
+connectDevice procFun device = set ([], [], False) ch
+ >>| appendTopLevelTask 'DM'.newMap True
( procFun device ch -||- catchAll (getSynFun device.deviceData ch) errHdl)
>>= \tid->upd (\d->{d&deviceTask=Just tid,deviceError=Nothing}) (deviceShare device)
>>| upd (\(r,s,ss)->(r,s++[MTSpec],ss)) ch
where
errHdl e = upd (\d->{d & deviceTask=Nothing, deviceError=Just e}) (deviceShare device) @! ()
+ ch = channels device
\end{lstlisting}
Figure~\ref{fig:handshake} shows the connection diagram. The client responds to