Skip to content

Function type signatures should allow more sophisticated matching criteria #143

Open
@braxtonmckee

Description

@braxtonmckee

Right now we can write

def f(x: int, y: int):
    ...

but we have no way of describing the idea that we want 'f' with two arguments that are the same, or some other more complex match.

One way to do this would be to allow an arbitrary python function to run to check the arguments. Another option would be to develop a grammar of "types" that can be passed to the Function signature to allow it to choose how it specializes. For instance, imagine we have an object called template. Then we could have

def f(x: template.X, y: template.X):
   ...

where the semantics are that we match arguments from left to right and when a template variable is encountered, its value is set and future versions of that pattern insist that the value matches. this could let you say things like f(x: Dict(int, template.X), y: Dict(template.X, str)) to insist that the two types covary in a meaningful way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions