legend-pure
legend-pure copied to clipboard
Provide a way to invoke generic functions with explicit type arguments
Feature Request
Description of Problem:
Suppose I want to define a type that models a bijective Map like so:
Class BiMap<K, V> {
to: Map<K, V>[1];
from: Map<V, K>[1];
}
Now I want to provide to users a convenient constructor method that just yields an empty instance of BiMap
:
function empty<K, V>(): BiMap<K, V>[1] {
^BiMap<K,V>(to=^Map<K,V>(), from=^Map<K,V>());
}
Such a function definition does not work for two reasons: First, PURE tries to find existing types named K
and V
. Second, there is no way to invoke the empty
function by explicitly specifying type parameters at invocation (type parameters are always implicit via supplied function arguments).