[Haskell-beginners] Problems with IO an laziness

Dmitry Mamontov mamontov.dp at gmail.com
Wed Feb 17 20:13:15 UTC 2016

I am a Haskell beginner. I've tried to write a tiny VM-like thing but ran
into a problems with IO and evaluation order.

Here is the full source code of this VM:
https://gist.github.com/mamontov-cpp/c4d8e2e46e7541c0c646 . This code is
supposed to read 4 strings and output them in reverse order.

While it seems to read some strings, it requests much more than one string
from user on each step of evaluation of meta-program, stored as array in
main function (which is just wrong).

I assume the problem with this program, is that the main state, being
immutable, seems to get re-evaluated on several steps inside of internal
parts of runProgram and runInstructionOrStop, forcing it to repeat
requesting data from user.

So, how can I prevent this main state from being re-evaluated in following
code ? Or is there any other problems, which I don't see?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160217/8e1ab32f/attachment.html>

More information about the Beginners mailing list