2 ms·
Didn't the post you are responding to say that? I suspect you didn't read past the example. The problem comes because you have to either use a single error fo
by taeric 8y ago
Didn't the post you are responding to say that? I suspect you didn't read past the example.
The problem comes because you have to either use a single error for two parts or deal with a tough explosion of types. No?
- masklinn 8y agoThere are known solutions to this problem: you can type-erase to a single supertype (e.g. Error/NSError[0]) or convert from the third-party's type to a first-party type[1] for instance. [0] https://developer.apple.com/documentation/swift/error https://developer.apple.com/documentation/swift/error [1] https://boats.gitlab.io/failure/ https://boats.gitlab.io/failure/
- KirinDave 8y agoIt's sort of amazing that you're replying to a post suggesting something I suggested, by re-suggesting what all 3 posts prior to you suggested. But as I've said, yeah you can do this. But it's unfortunate because it destroys a lot of information that's useful in the type signature. Haskell does this with exception hierarchies and some clever runtime casting attempts, but even that has ergonomic issues. What'd be really amazing is if we could get the totality checking of pattern matching but also the composability of exception handlers, and that's what the next generation of error handling primitives are trying to do.