It would be useful to be able to apply singleton to type variables as well as concrete types. As a motivating example consider this simple event bus:
interface _Subscriber[E]
def call: (E event) -> void
end
class EventBus
def subscribe: [E] (_Subscriber[E] subscriber, to: singleton(E)) -> void
def dispatch: (untyped event) -> void
end
Here I want to specify that EventBus#subscribe expects the subscriber to handle events of the type given as the to: argument.
It would be useful to be able to apply
singletonto type variables as well as concrete types. As a motivating example consider this simple event bus:Here I want to specify that
EventBus#subscribeexpects thesubscriberto handle events of the type given as theto:argument.