[swift-evolution] Proposal: An Either Type in the STL
Donnacha OisÃn Kidney
oisin.kidney at gmail.com
Thu Dec 10 12:57:39 CST 2015
If the analogy is to tuples, though, I would intuitively expect the other behaviour. Maybe something like:
let listOfProducts: [(Int, Bool)] = [(1, true), (2, false)]
let listOfSums: [(Int|Bool)] = [(|true), (2|)]
> On 10 Dec 2015, at 18:38, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>> On Dec 10, 2015, at 10:34 AM, Matthew Johnson <matthew at anandabits.com> wrote:
>>
>>> As an alternative to a semantically-neutral Either type, it might be worth considering the possibility of anonymous structural sum types (similar to how tuples are the structural analog of structs).
>>
>> John mentioned that these are a massive complication for type systems when I proposed them as a possible way to implement throwing multiple error types. Do you agree with that?
>
> There are definitely problems if you expect them to behave like unions (so that the type `T + T` == `T`) or be unordered (so that `T + U` == `U + T`), which would be intuitively expected.
>
> -Joe
>
> _______________________________________________
> 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/20151210/678f283a/attachment.html>
More information about the swift-evolution
mailing list