Skip to content

Type restrictions #84

Description

@sobolevn

For example, one may want to define a typeclass with type restriction, like this:

@typeclass
def map_(instance: Functor[T], function: Callable[[T], V] -> V:
    ...

So, when defining instances, we would have to watch for this contract.
This will typecheck:

@map_.instance(Maybe)
def map_(instance: Maybe[T], function: Callable[[T], V] -> V:
    return instance.map(function)

But, this will not typecheck:

@map_.instance(int)
def map_(instance: int, function: Callable[[int], V] -> V:
    return function(instance)

Activity

  1. added a commit that references this issue on Jun 3, 2021
    3b0885c
  2. added a commit that references this issue on Jun 11, 2021
    f1ac13b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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