Y
Hacker News
new
|
ask
|
show
|
jobs
by
rixed
1719 days ago
To be fair, in OCaml, Haskell or Rust the type "A | B" also had to be declared beforehand.
2 comments
Zababa
1719 days ago
Not exactly. For example, in Rust, you can do unions for traits:
https://play.rust-lang.org/?version=stable&mode=debug&editio...
. OCaml has the same system for its objects, where objects are structurally typed.
link
carlmr
1719 days ago
Yes, but it doesn't really change the way you could handle it, and what I wanted to point out is that it actually helps with type safety, enabling you to create total functions.
link