(* A simple Domain-Specific Language for image manipulation Language definition *) module type IMGDSL = sig type exp (* type of DSL expressions *) val int: int -> exp (* integer literal *) val load: string -> exp (* load from a file *) val display: exp -> exp (* display the image *) val it: exp (* the variable `it' *) val ( +% ): exp -> exp -> exp (* Binary opertions *) val ( -% ): exp -> exp -> exp val ( *% ): exp -> exp -> exp val ( <% ): exp -> exp -> exp val ( >% ): exp -> exp -> exp val ( =% ): exp -> exp -> exp val if_: exp -> exp -> exp -> exp (* if-then-else conditional *) val iterate: exp -> exp -> exp (* iterate img exp *) end (* iterate img exp the first argument must evaluate to an image the second argument expression is evaluated on each pixel of the image. The variable `it' is bound to the current pixel value. The result of evaluating the expression, which must be int, is stored in the current pixel. *) (* Task: specialize the interpreter `eval' to the given program. In other words, write a compiler for the DSL. *)