4 ms·
Pretty great until you come across a project with thousands of lines of code and 0 type signatures. At least Haskell warns you about top-level declarations with
by bno1 6y ago
Pretty great until you come across a project with thousands of lines of code and 0 type signatures. At least Haskell warns you about top-level declarations without type signatures. This is the error of the developer, true, but I think compilers should steer people away from doing such things.
- rwmj 6y agoFor OCaml, generate annot files by adding the -annot flag. Then in emacs you can do C-c C-t over any expression and it will tell you the type. Edit: But I do think you have a point. In our OCaml programs we enforce interface files (*.mli) for all modules (the rule is enforced by 'make check'). So at least between modules there is always documentation and an explicitly typed interface.
- c-cube 6y agoIn ocaml, install merlin or the upcoming ocaml-lsp, you mean :) It's excellent tooling and provides completion, jump to def, etc. Annot files are very limited in comparison.
- k__ 6y agoAren't they always displayed in a virtual line above?
- yawaramin 6y agoAre you talking about OCaml. It's widely accepted community practice to have type signatures in separate interface files. Those make it pretty easy to navigate the code.
- bno1 6y agoMy main issue was when making code modifications. If I wanted to add an argument to a function I would have to find and fix tens of calls to that function in order to convince the compiler to infer the type that I wanted so I could use its error messages to find and fix the rest of the calls. In hindsight, I should've written annotations by hand for functions I had to modify.
- yawaramin 6y agoIndeed, if you have an interface file which contains the function's type, you'll only need to change that one point to get all consuming modules to see the correct type.