[swift-evolution] [Pitch] Self.withoutSpecialization
T.J. Usiyan
griotspeak at gmail.com
Fri Jul 1 18:31:34 CDT 2016
Bump
On Fri, Jul 1, 2016 at 11:56 AM, T.J. Usiyan <griotspeak at gmail.com> wrote:
>
>
> ## The Issue
> Given
> ``` swift
> public protocol Zipper1D : CustomStringConvertible {
> associatedtype Element
> }
> ```
>
> We can almost write a `flatMap` which keeps the general identity of self
> and swaps out the Element in the output.
>
> ``` swift
> func flatMap<
> NewElement, SegmentOfResult : Collection, Output : Zipper1D where
> SegmentOfResult.Iterator.Element == NewElement, Output.Element ==
> NewElement>
> (_ transform: @noescape (Element) throws -> SegmentOfResult)
> rethrows -> Output
> ```
>
> ## The Proposal
> I propose that we allow `Type.withoutSpecialization`
>
> ``` swift
> func flatMap<
> NewElement, SegmentOfResult : Collection, Output : Zipper1D where
> SegmentOfResult.Iterator.Element == NewElement, Output.Element ==
> NewElement, Output.withoutSpecialization == Self.withoutSepcialization>
> (_ transform: @noescape (Element) throws -> SegmentOfResult)
> rethrows -> Output
> ```
>
>
> I recognize that generic protocols are another possible solution to this
> problem. I am pitching this because of how much closer this idea seems to
> being realized.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160701/6f546dac/attachment.html>
More information about the swift-evolution
mailing list