Re:Tagged unions, or ‘variants’, in C
by k__ on Monday June 26, 2017 @07:04AM
(#14635787)
So they're a bit like open classes in Ruby or implicit conversions in Scala?
[ Parent
| on HN ]
If you're familiar with Scala, then type classes in Haskell are pretty close to traits in Scala (but not implicit conversions, which can make use of traits, but are an orthogonal language feature). They're also close to Rust's traits, it you're familiar with Rust.
I see. Thanks.
They achieve the same result, but in a quite different way. I see them as decoupling the "implements X" piece of a traditional OO class in a language that has interfaces from the class itself.