|
|
|
|
|
by flohofwoe
663 days ago
|
|
> That’s a lot of valuable information, at a glance ...if you know how to decode it. That example looks like one of those C++ SFINAE hacks, e.g. trying to bend the template/generics syntax beyond what it was designed for. If Rust APIs want to go that way (of overly expressive strong typing) then Rust really should offer a better syntax for describing such types. But it's not even clear to me if such strongly typed APIs are even a good idea. From my experience in C++ and (especially) Typescript with similar APIs, it's a PITA to work with in real world projects, and on both sides of the API. |
|
The fact that Haskell is not very different from Rust in the type syntax complexity shows that this type is just fundamentally "complex", because it is composed of multiple composable types. (I will personally avoid `Either` because I think an explicit enum is better here, but otherwise everything is independent from each other.) And an equivalent C function will do the same thing but without any type declaration and ad-hoc error code and/or convention, which never works well in practice.
[1] Some Rust crates do still attempt this, like the `typenum` crate, but I would not recommend them in general because they are really awkward to use.