3 ms·
As a Haskell dev about to get into Rust (and appreciates occasional parallels to OCaml) I found this very insightful. I especially like the attention given to
by vq 12y ago
As a Haskell dev about to get into Rust (and appreciates occasional parallels to OCaml) I found this very insightful. I especially like the attention given to the tables of language literals.
Not that it takes away from the purpose of the post but I couldn't help but see some issues in the Haskell code.
The code under "Recursive data structures" is not valid, top-level code in a Haskell source-file isn't evaluated like in Ocaml, I'd remove the "let" keywords and put "main = " in front of the putStrLn function (which is also misspelled).
As others have mentioned, the ADT example is wrong, you need to use "data" instead of "type", and the convention for the optional type in Haskell is "data Maybe a = Nothing | Just".
hello x =
test x
This might be intentional, but it's very unconventional to put a newline after the equality sign in that short function.
if v /= 1 then collatz v
else return ()
This is better written as:
when (v /= 1) (collatz v)
and compares better with the Rust and OCaml code.