Hi everyone!<br><br>(First of all, I don&#39;t know Monads!)<br><br>I made
a GCL (Guarded Command Language) Compiler and Interpreter for my
Languages and Machines course in my University with alex, happy and
ghc. I still have a doubt:<br><br>1)
Since Haskell is Lazy, and my GCL program is being interpreted in
Haskell then my GCL is Lazy too (I know is not as simple as that but
believe me, somehow it is behaving lazy). The problem is that it can&#39;t
be lazy (said to me by my teacher on monday) so I tried using seq, but it didn&#39;t work, I&#39;ll
paste the code after this:<br>
Programs in GCL like:<br>a)<br>var i : value<br>main<br>    i &lt;- 1 / 0<br>end<br><br>b)<br>
var i : value<br>
main<br>
    i &lt;- 1 / 0;<br>    show i<br>
end<br><br>c)<br>
var i : value<br>var foo : array of 2<br>
main<br>
    i &lt;- foo[42]<br>
end<br><br>d)<br>
var i : value<br>var foo : array of 2<br>
main<br>
    i &lt;- foo[42];<br>    show i<br>
end<br><br>act like this:<br>a and c finish interpretation<br>b throws division by zero error and finish interpretation<br>d throws index out of bounds error and finish interpretation<br><br>Now the code:<br>(it is in Spanish. ListLValue is a List of L-Values for the assigments,
ListExpr is the list of Expressions to be assigned, Tabla is the Symbol
Table (Data.Map), actualizarVar updates a Variable in the Symbol Table
with the new value &quot;valor&quot;, ActualizarArray updates the position
&quot;indice&quot; of an array in the Symbol Table. evalExpr evaluates an
arithmetic Expression and returns an Int. Inside evalExpr are the
verifications for division by zero of modulo by zero.)<br>
<br>evalAsignacion:: ListLvalue -&gt; ListExpr -&gt; Tabla -&gt; Tabla<br>evalAsignacion [] [] tabla = tabla<br>evalAsignacion ((Lid id):valueList) (expr:exprList) tabla =<br>    let valor = (evalExpr expr tabla)<br>    in valor `seq` evalAsignacion valueList exprList (actualizarVar id valor tabla)<br>


evalAsignacion ((LArrayPosition id exprArray):valueList) (expr:exprList) tabla =<br>    let valor = (evalExpr expr tabla)<br>        indice = (evalExpr exprArray tabla)<br>    in valor `seq` indice `seq` evalAsignacion valueList exprList (actualizarArray id indice valor tabla)<br>


<br>evalExpr:: Expr -&gt; Tabla -&gt; Int<br>evalExpr expr tabla =<br>    let salida = (snd (evalAritmetico expr tabla))<br>    in salida `seq` if (isLeft salida) then error (getLeft salida)<br>                              else getRight salida<br>


<br>--((Int,Int) is the Line and Colum, that&#39;s for error reporting)<br>evalAritmetico :: Expr -&gt; Tabla -&gt; ((Int,Int),(Either String Int))<br>--LET ME KNOW IF YOU NEED THIS PART TOO<br><br>
<br><div id=":wh" class="ii gt">Thanks in advance,<br><font color="#888888">
<br>Hector Guilarte</font></div>