> On Feb 28, 2017, at 09:38, Adrian Zubarev via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> I also thought about the Either type.
> 
> enum Either<A, B> where A != B {
>     case -> A
>     case -> B
> }

I was thinking about using it as a workaround for not having typed throws:
protocol MyErrorType: Error {...} // all my custom errors conform to this
enum MyError<T: MyErrorType, U: Error> : Error where !(U: FixableError) {
    case myError(T)
    case otherError(U)
}

Which ensures that, if an instance of "MyError" is .otherError, the payload 
will actually be an other error (or at least not an error that originated with 
any of my code).

Seems like if the program logic is intended to ensure that something is only a 
value of an exact type and not some sort of subtype, there ought to be a way to 
express that to the type system.

- Dave Sweeris
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to