3 ms·
OCaml's type inference is truly amazing, makes it such a delight to write statically typed code - reading it on the other hand... But I think that's easily sol
by miningape 1y ago
OCaml's type inference is truly amazing, makes it such a delight to write statically typed code - reading it on the other hand...
But I think that's easily solved by adding type annotations for the return type of methods - annotating almost anything else is mostly just clutter imo.
- Supermancho 1y agoAnnotations would be a substitute for writing the return type. Extra code for a shortcut seems like the worst solution.
- miningape 1y agoI don't mean Java annotations, those would be too clunky - in OCaml a type annotation is really just adding `: <typename>` to variables, function return types, etc. so fibonacci could look like this ``` let rec fib n = match n with | 0 -> 1 | 1 -> 1 | _ -> fib (n - 1) + fib (n - 2) ``` or with annotations it becomes this: ``` let rec fib (n: int): int = // Same as above :) ```