Skip to content

Provide a way to invoke generic functions with explicit type arguments #426

@gbrgr

Description

@gbrgr

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions