|
|
|
|
|
by lobster_johnson
3353 days ago
|
|
Sorry, I should have been clearer. As I'm aware you have the choice between several ways: let foo : unit -> unit = <code>
let foo = function
| <pattern match stuff>
let foo = (function () -> <code>)
let foo = (fun () -> <code>)
I'm not an expert, but I guess this awkwardness comes from OCaml not having a dedicated function-declaration syntax; so if you do: let foo = do_stuff + 42;
...then you're obviously just defining a variable, which is evaluated right away. Which means that the only way to define a "procedure"-type function that takes zero arguments is the above.> What do you mean by "readline" support? Readline is a library that adds a line editor to a REPL. It adds keyboard shortcuts (arrow keys etc.), history, autocompletion, and so on. Unlike almost every single REPL out there (Python, Ruby, Haskell, etc.), OCaml doesn't come with built-in support, as far as I've been able to determine. You have to run "rlwrap ocaml" to get Readline into your REPL. |
|
There is a great advanced REPL for OCaml if you need something beyond simple stuff:
https://github.com/diml/utop