# \[Pitch N+1\] Typed Throws

**URL:** <https://forums.swift.org/t/pitch-n-1-typed-throws/67496>\
**Category:** Pitches\
**Created:** [September 25, 2023, 4:25am UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496 "2023-09-25T04:25:05Z")\
**Posts on this page:** 1\
**Showing post:** 59

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [September 26, 2023, 6:42am UTC](https://forums.swift.org/t/pitch-n-1-typed-throws/67496/59 "2023-09-26T06:42:48Z")

</div>

> #### [Protocol conformance and refinements](https://github.com/DougGregor/swift-typed-throws/blob/master/SE-XXX%20Typed%20throws.md#protocol-conformance-and-refinements)
> 
> Protocols should have the possibility to conform and refine other protocols containing throwing functions based on the subtype relationship of their functions. This way it would be possible to throw a more specialised error or don't throw an error at all.

All this discussion of parity between `Result`, `Task`, and typed throws, alongside the minor source-breaking changes we're willing to incur in Swift 6 to deliver on the overall feature (all of which I vehemently agree with), makes me sad that it's likely not in scope here to have the same subtyping niceties when it comes to protocol requirements and that other error handling mechanism we have: optional return values.

My pet use case has the same rationale as expressed here: if I have an infinite sequence, it would be more expressive if I could implement the iterator requirement as `next() -> Element` instead of `next() -> Element?`, but alas this is not regarded as kosher in present-day Swift. It does seem of-a-kind to what we're dealing with here, though, since returning an optional `Element?` is notionally isomorphic to `throws(Void) -> Element`, for which this proposal would accommodate subtyping the relationship...

---

_[View the full topic](https://forums.swift.org/t/pitch-n-1-typed-throws/67496)._
