Lab3: Haskell and side effects of function calls

0 views
Skip to first unread message

Marcus Hedenström

unread,
Mar 7, 2010, 2:50:51 PM3/7/10
to proglang-c...@googlegroups.com
Hi everyone,

We're finishing up our interpreter for assignment 3 in Haskell, the only thing left is how to call the functions, stored as lambda functions in our environment. We are using a state monad.

Now, the thing is in Haskell, funcitons are not allowed to have side effects, so it seems we cannot both print output to stdout, and at the same time produce a return value from our evalExp function.

Example:

evalExp expr
... something something...
[execute function, e.g. printInt]
something... something...
return [some value]

Here, the third line executes function and tries to return from evalExp, but we want to continue and return a value.
We have tried to "extract" the contents of the IO monad (val <- f x) produced by printInt et.al. but we can't seem to get the types right.

If anyone has any advice, we'd really appreciate it. :)


Thanks!!

Reply all
Reply to author
Forward
0 new messages