[swift-evolution] [Idea] Generic subscripts

Matthew Johnson matthew at anandabits.com
Wed Aug 3 08:35:27 CDT 2016

> On Aug 3, 2016, at 4:16 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>> On Aug 3, 2016, at 1:57 AM, Tino Heth <2th at gmx.de> wrote:
>>> Since RangeExpression is a protocol compatible with any index type, it has to have an associated type
>> I haven't read all linked information, but would the situation change with generic protocols?
>> Thinks like "AnyGenerator" afaics would be superfluous if we had "protocol Generator<Type>", and the same might be true for RangeExpression.
> No, this is not an appropriate use case for generic protocols. (Nor is Generator/IteratorProtocol, for that matter.)
> Generic protocols would be for cases where a single concrete instance can conform to a protocol using several different types. Genuine use cases for that do exist, but they're few and far between.

Yes, this feature is called “multi-parameter type classes” in Haskell.  Those interested in proposing it in Swift might be interested in looking at how the feature is used in Haskell.

> -- 
> Brent Royal-Gordon
> Architechies
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list