Is there any way to specify a generic type which is constrained to either a type or an optional type?

For now. My pitch for generalized supertype constraints was well received. We just can't move it forward until somebody volunteers to work on implementation. If / when that happens the compiler would recognize the Bool: Bool? relationship in a generic constraint.

Also for now. Hopefully we can express closed protocols in the language eventually. This has been the topic of several threads in the past.

1 Like