Anthony Bias
Anthony Bias

Reputation: 646

Ocaml multi-line function in REPL

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.

Upvotes: 1

Views: 205

Answers (1)

axr
axr

Reputation: 416

Your example is incorrect, a proper way to do it will be

let theFun: int -> int = fun x ->
    let foo = x in
    foo;;

Upvotes: 6

Related Questions