# Pitch: Genericizing over annotations like throws

**URL:** <https://forums.swift.org/t/pitch-genericizing-over-annotations-like-throws/20376>\
**Category:** Pitches\
**Tags:** generics\
**Created:** [February 12, 2019, 3:07am UTC](https://forums.swift.org/t/pitch-genericizing-over-annotations-like-throws/20376 "2019-02-12T03:07:58Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [February 12, 2019, 11:41pm UTC](https://forums.swift.org/t/pitch-genericizing-over-annotations-like-throws/20376/10 "2019-02-12T23:41:22Z")

</div>

Another interesting future direction we could take to address polymorphism over `throws` specifically would be to adopt typed `throws`, and make the error type an independent type argument of all function types. This would mean that a type that doesn't throw effectively throws `Never`, and one that `throws` without a type by default throws `Error`:

```swift
(X, Y, Z) -> W === (X, Y, Z) throws Never -> W
(X, Y, Z) throws -> W === (X, Y, Z) throws Error -> W

```

This would allow protocols to be generic over throwing and nonthrowing implementations by making the error a separate associated type:

```swift
protocol MyIterator {
  associatedtype Element
  associatedtype Error: Swift.Error

  mutating func next() throws Error -> Element
}

struct NonthrowingImplementation: MyIterator {
  mutating func next() -> Int // conforms with Error == Never
}
struct ThrowingImplementation: MyIterator {
  mutating func next() throws -> Int // conforms with Error == Swift.Error
}
```

---

_[View the full topic](https://forums.swift.org/t/pitch-genericizing-over-annotations-like-throws/20376)._
