Do you think Haskell is worth learning over Ocaml? @pkw I have never used OCaml ...
Ramin Honary @ramin_hal9001@fe.disroot.org
Do you think Haskell is worth learning over Ocaml?
@pkw I have never used OCaml or Idris for any real software development, but I know the type checker for OCaml is basically the same as Haskell, they are both implementations of the System-F calculus. There are syntactic differences as well, but the biggest difference is that OCaml is not lazily evaluated by default, and this necessitates constructs like recursive let bindings. In Haskell, all let bindings are recursive since they are lazily evaluated.
I think Haskell’s lazy evaluation results in much more elegant code with a mathematical style to it. For example, you can declare infinitely large recursive data structures over which you can pass a filter, as long as the filter itself terminates the program will terminate even though it generates an infinitely large data structure. This is because the data structure is evaluated lazily, so only the elements that are filtered are actually generated in memory. This is sort-of like how a mathematician may declare a set of objects, like a function over the set of all integers filtered by some constraint.
Idris uses a completely different type system, it is an implementation of the Calculus of Constructs, which makes it more similar to Coq. The idea of these languages is that everything you write in code is a type declaration, and the actual data and functions that are computed at runtime are derived from the types you declare. In other words, you declare to the compiler what program you want to exist, the compiler first proves if your program’s type is valid, and in the process of proving it’s validity, it writes the runtime program for you.
I have heard people who use Idris say it is often less practical than Haskell because sometimes the types must be so specific. Sometimes it would be easier to just write the functions yourself like you would do with Haskell, rather than in Idris trying to coax the type checker into deriving the function you want to write.