Hacker News new | ask | show | jobs
by dwohnitmok 2099 days ago
Not many language have cross-module type inference. For example I'm pretty sure Haskell does not have cross-module type inference (you need `.hs-boot` files to help it along if you want cyclic modules for example). So in that sense OCaml's type inference is no weaker than other languages with global type inference.

And in fact type inference is generally not what slows down compilation. It is often barely any more expensive than type checking (and indeed for languages with global type inference a viable way to implement type checking is to run type inference and then compare the generated type signature with the annotated signature). This is especially true for OCaml which requires definitions to be in order or otherwise explicitly marked as recursive (so the type inferencing algorithm can immediately add a term's inferred type to the current typing judgment as a known type). What's slow is usually recursive implicit definitions and optimizations. This means typeclass-heavy signatures for Haskell and frequent use of recursive implicits in Scala.