Assume MLreadint and MLwriteint are primitives with side effects for input-output and consider the ML expression add1
Fantastic news! We've Found the answer you've been seeking!
Question:
Assume MLreadint and MLwriteint are primitives with side effects for input-output and consider the ML expression add1 of type int: let val x = MLreadint() in MLwriteint(x+1); x end (i) Give an equivalent expression that uses the IO monad instead of side-effects and state its type. (ii) Give a function run2diff that can be applied to your answer to part (c)(i). When so applied it should give a value in the IO monad which corresponds to ML code that runs add1 twice and returns the difference between the values read.
Related Book For
Posted Date: