1
0
mirror of https://github.com/dhil/phd-dissertation synced 2026-03-13 02:58:26 +00:00
This commit is contained in:
2021-05-20 11:04:54 +01:00
parent 76d9c00e19
commit d1a91fb197
2 changed files with 12 additions and 10 deletions

View File

@@ -356,6 +356,7 @@
\newcommand{\return}{\dec{Return}} \newcommand{\return}{\dec{Return}}
\newcommand{\faild}{\dec{withDefault}} \newcommand{\faild}{\dec{withDefault}}
\newcommand{\Free}{\dec{Free}} \newcommand{\Free}{\dec{Free}}
\newcommand{\FreeState}{\dec{FreeState}}
\newcommand{\OpF}{\dec{Op}} \newcommand{\OpF}{\dec{Op}}
\newcommand{\DoF}{\dec{do}} \newcommand{\DoF}{\dec{do}}
\newcommand{\getF}{\dec{get}} \newcommand{\getF}{\dec{get}}

View File

@@ -1254,16 +1254,17 @@ operations using the state-passing technique.
\el \el
\] \]
% %
The interpreter pattern matches on the shape of the monad (or The interpreter implements a \emph{fold} over the computation tree by
equivalently computation tree). In the case of a $\Return$ node the pattern matching on the shape of the tree (or equivalently monad). In
interpreter returns the payload $x$ along with the final state value the case of a $\Return$ node the interpreter returns the payload $x$
$st$. If the current node is a $\Get$ operation, then the interpreter along with the final state value $st$. If the current node is a $\Get$
recursively calls itself with the same state value $st$ and a thunked operation, then the interpreter recursively calls itself with the same
application of the continuation $k$ to the current state $st$. The state value $st$ and a thunked application of the continuation $k$ to
recursive activation of $\runState$ will force the thunk in order to the current state $st$. The recursive activation of $\runState$ will
compute the next computation tree node. In the case of a $\Put$ force the thunk in order to compute the next computation tree node.
operation the interpreter calls itself recursively with new state In the case of a $\Put$ operation the interpreter calls itself
value $st'$ and the continuation $k$ (which is a thunk). recursively with new state value $st'$ and the continuation $k$ (which
is a thunk).
% %
By instantiating $S = \Int$ we can use this interpreter to run By instantiating $S = \Int$ we can use this interpreter to run