M
Modular13mo ago
stu002

can I implement a trait for a third party type?

Am I right in my understanding that I can’t implement a trait I control for a type that I don’t control? For example I couldn’t implement a trait requiring an addition operator for any built in integer types? This is a point of difference with Rust traits and Haskell type classes?
2 Replies
Arthur Evans
Arthur Evans13mo ago
You're correct. You cannot currently implement a trait for a type that you don't control. The team fully intends to fix this, but there are a couple of possible approaches (for example, allowing implicit conformance to traits, or an extension mechanism like Swift (in Rust, adding an implementation I think). Stay tuned.
stu002
stu002OP13mo ago
That’s great — Mojo is looking better and better. Thanks to all involved!
Want results from more Discord servers?
Add your server