I'm also in favor of providing the ability to specify the type of the error for the result. It provides self-documenting and type safety advantages over the generic Error that really makes the type much more useful.
The ideal would be to have the two possible syntax (Result<T> and Result<T,E>) , but i'm not sure how feasible that is. On Thu, Nov 2, 2017 at 7:15 PM, Jon Shier via swift-evolution < swift-evolution@swift.org> wrote: > You don’t lose it, it’s just behind `Error`. You can cast out whatever > strong error type you need without having to bind an entire type to it > generically. If getting a common error type out happens a lot, I usually > add a convenience property to `Error` to do the cast for me. Plus, having > to expose an entire new error wrapper is just a non starter for me and > doesn’t seem necessary, given how Result is currently used in the community. > > > Jon > > > On Nov 2, 2017, at 2:12 PM, Dave DeLong <sw...@davedelong.com> wrote: > > I think I’d personally rather see this done with a generic error as well, > like: > > enum GenericResult<T, E: Error> { > case success(T) > case failure(E) > } > > And a typealias: > > typealias Result<T> = GenericResult<T, AnyError> > > This would require an “AnyError” type to type-erase a specific Error, but > I’ve come across many situations where a strongly-typed error is *incredibly > *useful, and I’d be reluctant to see that thrown away. > > Dave > > On Nov 2, 2017, at 12:08 PM, Jon Shier via swift-evolution < > swift-evolution@swift.org> wrote: > > Swift-Evolution: > I’ve written a first draft of a proposal to add Result<T> to the standard > library by directly porting the Result<T> type used in Alamofire to the > standard library. I’d be happy to implement it (type and tests for free!) > if someone could point me to the right place to do so. I’m not including it > directly in this email, since it includes the full implementation and is > therefore quite long. (Discourse, please!) > > https://github.com/jshier/swift-evolution/blob/master/ > proposals/0187-add-result-to-the-standard-library.md > > > Thanks, > > Jon Shier > > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution > > > > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution > >
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution