3 ms·
Maybe a bit off topic. I've always heard that traits in rust are basically just type classes in haskell. But I'm not quite sure how you would implement this tr
by jimmyhmiller 11y ago
Maybe a bit off topic.
I've always heard that traits in rust are basically just type classes in haskell. But I'm not quite sure how you would implement this trait as a typeclass.
Specifically, from what I'm seeing here is that if you just implement From you've also now implemented Into. Is there an analog in haskell? I also can't figure out how to specify a type class that is parametrized the way into is.
Can anyone help by shedding some light on how you might go about this in haskell? Or where traits in rust differ from typeclasses in haskell?
- rapala 11y agoStandard Haskell has only single parameter type classes. With MultiParamTypeClasses you can define class Into a b where into :: a -> b Note that From would be the exact same class. I guess the distinction in Rust is relevant because of ownership.