Hacker News new | ask | show | jobs
by the_benno 1867 days ago
Most OCaml users I know use emacs with tuareg-mode and merlin (or the equivalent in vim). Once you've got that set up (and it's a breeze these days with opam user-setup) it's super easy to navigate an OCaml code base and access type information on demand.

This is a feature, not a bug -- getting the type of an arbitrary expression is two keystrokes away, but there's no visual clutter from excessive type annotations. And the tooling goes well beyond this one feature.

Working in OCaml without merlin+tuareg feels like having a hand tied behind your back (to me), so I feel your pain. This certainly raises the barrier to entry slightly, but I think it's worth it for the convenience and ergonomics once you're past that initial barrier.

3 comments

Why have it 2 strokes away when it can be 0 strokes away? I don't mean this for every definition, just for top-level definitions and class members and methods. I'm a fan of type inference and clean code too, but I also want the code to be documented and human-readable.
in many cases you're probably right that mandatory type annotations would improve readability. Taking the rhetorical question very literally, though, there are some times when having it two keystrokes away is very helpful. I often query the type of a large expression (e.g. a partially applied function to remember what argument comes next) or the signature of some module
After having worked many years with OCaml and a few years with Rust, I prefer the latter's approach of requiring types in function declarations (or equivalently requiring a .mli in OCaml). This makes browsing in code much faster and removes sources of incomprehension.

YMMV

> having to depend on editor support for basic cognition tasks

I'm having horrendous Java flashbacks here, please don't trigger me.