[swift-evolution] Generic `typealias`s
T.J. Usiyan
griotspeak at gmail.com
Fri Dec 4 16:35:32 CST 2015
I concur and I think that there is should be more to this idea. I, at
least, would want partial specialization as part of this. Consider Either
and Result:
`enum Either {
case .Left
case .Right
}
typealias Result<SuccessValue> = Either<NSError, SuccessValue>`
How (can I?) specify just one of the types or, possibly, constrain the left
side so as to avoid the need to provide a concrete type "NSError" there?
This next bit is probably another proposal. Assuming that that gets sorted
out, it would be useful to alias methods, properties, cases, etc for the
new name. `<Some keyword> case Result.Success = case Either.Left`
TJ
On Fri, Dec 4, 2015 at 12:04 PM, Dapeng Gao <gdapeng at icloud.com> wrote:
> It would be handy if Swift can support generic `typealias`s, which would
> probably look like this:
>
> typealias Handler<Element> = [Element] -> Void
>
> One common way to achieve this is to define a generic `struct` and use a
> nested `typealias`:
>
> struct HandlerWrapper<Element> {
> typealias Hander = [Element] -> Void
> }
>
> HandlerWrapper<SomeType>.Hander
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151204/facbbe0e/attachment.html>
More information about the swift-evolution
mailing list