CD
Size: a a a
CD
TK
CD
TK
CD
[
Т8
std::function?Т8
Т8
[
[
TK
TK
CD
SP
SP
classes project.Supports[TypeClassName] type. It has some problems.Supports[TypeClassDefinedByFunction]. Why? Because mypy thinks that Supports[to_json] (when to_json is a FunctionDef node) is not valid as a type. It is related to how semantic analyzer works. I am pretty sure that this will stay with us for a long type.Supports[] around Python classes.class ToJson(Protocol):
def __call__(self, arg: int) -> str:
...
to_json = typeclass(ToJson)
# It is the same as:
# @typeclass
# def to_json(arg) -> str:
# ...
@to_json.instance(int)
def _to_json_int(arg: int) -> str:
return str(arg)
@to_json.instance(str)
def _to_json_str(arg: str) -> str:
return arg
ypeclass cannot be applied to python classes, because mypy does not support it. So, we would have to stick to this two-step syntax.CD
CD
TK