I think it should be possible to use meta types constrainted to protocols in the signature of the init(attachedTo:)
.
struct Flag {
init(attachedTo archetype: @escaping (AsyncSequence.Type) -> MyProtocol.Type)
}
@Flag
struct MyType<T: AsyncSequence>: MyProtocol { ... }
It can be challenging through to express everything that can go into where
clause.
I think with generalized existentials, it should be possible to capture where
clause by combining all generic arguments into a dummy tuple type:
@Flag
struct Zipper<A: Sequence, B: Sequence> where A.Element == B.Element {
typealias Element = A.Element
}
struct Flag {
init(attachedTo archetype: @escaping (any <A: Sequence, B: Sequence> (A, B).Type where A.Element == B.Element) -> Sequence.Type)
}
But even this does not allow to capture the fact that Element
of the resulting sequence type is the same as element of A
and B
.