I’m trying to write a multi-line function to use in an OCaml REPL. I’ve already seen this question, but the syntax suggested doesn’t seem to work when using it in a REPL.
To use a contrived example, I can’t get the following to compile:
let theFun: int -> int = fun x ->
let foo = x;
foo;;
When I enter it without the ";;" in this online REPL, they get added in anyway and it gives me a syntax error. When I use a REPL on my local machine, the input won’t get evaluated unless I include the ";;", and that gives me a syntax error as well.
>Solution :
Your example is incorrect, a proper way to do it will be
let theFun: int -> int = fun x ->
let foo = x in
foo;;