bp Assume MLreadint and MLwriteint are primitives with side effects…
Question Answered step-by-step bp Assume MLreadint and MLwriteint are primitives with side effects… bpAssume MLreadint and MLwriteint are primitives with side effects for inputoutput and consider the ML expression add1 of type int:let val x = MLreadint() in MLwriteint(x+1); x end(i) Give an equivalent expression which uses the IO monad instead ofside-effects, and state its type. (ii) Give a function run2diff which can be applied to your answer topart (c)(i). When so applied it should give a value in the IO monad whichcorresponds to ML code that runs add1 twice and returns the differencebetween the values read. (d) State what happens when attempting to compile and execute the following Javafragment (explaining the origin of any error messages or exceptions which mightarise).Object n = new Integer(42), o = new String(“Whoops”);Object [] v;Integer [] w = new Integer[10];v = w;v[4] = n;v[5] = o; [4 marks](e) Consider the Java code:Object n = new Integer(42);ArrayList extends Object> v1;ArrayList


