Rust in the 6.2 kernel
Rust in the 6.2 kernel
Posted Dec 3, 2022 0:58 UTC (Sat) by nybble41 (subscriber, #55106)In reply to: Rust in the 6.2 kernel by mlindner
Parent article: Rust in the 6.2 kernel
It's true that you could just create your own custom enum type instead (which would be isomorphic to some tree of nested `Either` types) but your custom type won't benefit from any functions the standard library might provide for working generically with values which might be "either" one type or another. For example, partitioning a list of `Either<A,B>` into a list of `A` and a list of `B`. I'm not as familiar with what Rust provides for working with `Either` values but in Haskell the `Either` type is a key component of the Arrow abstraction, a more powerful (albeit less popular) alternative to monads, where they are used to represent conditional processing (`ArrowChoice`). It also benefits from ready-made instances of `Bifunctor`, `Bifoldable`, and `Bitraversable`.
