\begin{slide}{Abstrakte Syntax (Anweisungen)}

\begin{verbatim}
data Identifier = Identifier String

data Statement = Assign Identifier Expression
    | Iterate Expression Statement

type Program = [ Statement ]
\end{verbatim}

\end{slide}

\begin{slide}{Semantik (Anweisungen)}

\begin{verbatim}
import qualified Data.Map as M

type Environment = M.Map Identifier Integer

execute :: Environment -> Statement -> Environment

run :: Program -> Environment
\end{verbatim}

\end{slide}

\begin{slide}{Semantik (mit Maybe)}

\begin{verbatim}
data Expression = ... | Reference Identifier
evaluate 
    :: Environment -> Expression -> Integer ??
    :: Environment -> Expression -> Maybe Integer
evaluate e x = case x of 
    Reference i -> M.lookup i e
    Plus l r -> case ( evaluate e l ) of
        Nothing -> Nothing
        Just a  -> case ( evaluate e r ) of
            Nothing -> Nothing
            Just b  -> Just ( a + b )
\end{verbatim}
das schöner hinschreiben mit \emph{Monaden} und \emph{do-Notation}

\end{slide}


