It seems like you don't need API-specific typed errors to achieve that, though. You could have something where there's one Error type but APIs can provide a nonexhaustive set of subtypes they may produce, for documentation purposes
Conversation
Yeah, and that's roughly how the Error trait works in Rust actually. It's just not nearly as ergonomic as matching an enum
2
3
i had a great convo with a few months ago about how to match on trait objects like non exhaustive enums and how we might do derived “vtable impls” to let enums play as trait objects
i had several other much worse ideas about enum/trait obj equivalence too
2
1
6
yeah imo enums should be traits over their variant types and basically just "inline trait objects", and we should get the exact same treatment in reverse
3
2
9
Kind of going backwards to Scala’s encoding of enums (using sealed traits)?
1
5
Funnily enough, Scala 3 (Dotty) now has Rust inspired sugar over sealed traits: dotty.epfl.ch/docs/reference - they have GADTs too though which I would looove in Rust.
1
3
Wg traits and all the work on chalk is geared towards GATs and specialization and shit
1
1
Show replies





