Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading