What is meant by a monad in a programming language, giving the two fundamental operations of a monad alg with their types
Describe the tasks that should be carried in implementing a front end for this language and any difficulties that might be encountered. Suppose that the target virtual machine is stack-oriented and that the stack elements are integer values, and addresses can be stored as integers. Explain which other features are required in such a virtual machine.
(a) Explain on what is meant by a monad in a programming language, giving the two fundamental operations of a monad alg with their types. [3 marks]
(b) Consider the use of a monad for input-output. For the purposes of this question, take the IO monad as including two operations readint and writing which respectively read integers from stdin and write integers to stout. Give the types of these operators. [2 marks]
(c) 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. Give a brief and rudimentary clarification of the standards of how the language
coming about because of part (b) may be utilized to make a sentence structure analyser taking a
token stream as information (by means of calls to work lex()) and giving as result.
let rec is_even n = if n = 0 then true else is_odd (n – 1) and is_odd n = if n = 0 then false else is_even(n – 1) [8 marks] 4 CST.2016.3.5 4 Compiler Construction Consider writing a compiler for a simple language of expressions given by the following grammar, e ::= n (integer) | ? (read integer input from user) | e + e (addition) | e − e (subtraction) | e ∗ e (multiplication) | (e, e) (pair) | fst e (first projection) | snd e (second projection)
theoretical language structure tree relating to. 6 CST.2016.1.7 6 Numerical Methods A picnicker brings hot black coffee and cold milk in two identical insulated flasks and then mixes them for his drink. His friend claims that the drink would have ended up the same temperature if he had mixed the two at home and brought one flask. Note: The temperature of an object is the heat energy within it divided by its heat capacity.