Remix.run Logo
edwintorok 10 months ago

That can be indeed very confusing when you initially learn the language. However there are 3 things that can help:

* An auto-formatter (ocamlformat integration in your editor, or ocaml-top) that shows how the actual nesting looks like

* You can add ;; at the end of a top-level function to get a syntax error at a better location

* Use the LSP integration of your editor which will show you where the error is as you type, so you catch the problem early

IshKebab 10 months ago | parent [-]

> Use the LSP integration of your editor which will show you where the error is as you type, so you catch the problem early

Yeah I do have this set up and it's a very good LSP, but unfortunately frequently if you get the nesting wrong the error is like "the entire rest of the file is wrong". It's often not very helpful.

That's not unique to OCaml. C style syntaxes can give "everything after this point is an error" if you get brackets wrong, but it's much easier to figure out what you did wrong.