Skip to content

Type restrictions #84

Closed
Closed
@sobolevn

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)

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