\begin{lstlisting}[label={lst:bcview},caption={Bytecode view}]
:: ByteCode a p = BC (RWS () [BC] BCState ())
:: BCValue = E.e: BCValue e & mTaskType, TC e
-:: BCShare = {
- sdsi :: Int,
- sdsval :: BCValue
+:: BCShare =
+ { sdsi :: Int
+ , sdsval :: BCValue
}
-:: BCState = {
- freshl :: [Int],
- freshs :: [Int],
- sdss :: [BCShare]
+:: BCState =
+ { freshl :: [Int]
+ , freshs :: [Int]
+ , sdss :: [BCShare]
}
class toByteCode a :: a -> String
happens via multiple steps. First a fresh identifier is grabbed from the state.
Then a \CI{BCShare} record is created with that identifier. A \CI{BCSdsFetch}
instruction is written and the body is generated to finally add the share to
-the actual state. The exact implementation is shown in
-Listing~\ref{lst:shareview}.
+the actual state with the value obtained from the function. The exact
+implementation is shown in Listing~\ref{lst:shareview}.
\begin{lstlisting}[label={lst:shareview},%
caption={Bytecode view for \texttt{arith}}]
instance sds ByteCode where
sds f = {main = BC (freshs
- >>= \sdsi->pure {BCShare | sdsi=sdsi,sdsval=BCValue 0}
- >>= \sds->pure (f (tell` [BCSdsFetch sds]))
- >>= \(v In bdy)->modify (addSDS sds v)
- >>| unBC (unMain bdy))}
+ >>= \sdsi->pure {BCShare | sdsi=sdsi,sdsval=BCValue 0}
+ >>= \sds->pure (f (tell` [BCSdsFetch sds]))
+ >>= \(v In bdy)->modify (addSDS sds v)
+ >>| unBC (unMain bdy))
+ }
pub (BC x) = BC (censor (\[BCSdsFetch s]->[BCSdsPublish s]) x)
addSDS sds v s = {s & sdss=[{sds & sdsval=BCValue v}:s.sdss]}