> I never once recall an instant where I was saying "Uh uh, this type signature is driving me craaazy"
For example, this is ugly in Python:
def handler(on_error: Callable[[int, Exception], None]):
For example, this is ugly in Python:
def handler(on_error: Callable[[int, Exception], None]):
from typing import Protocol
class ErrorHandler(Protocol):
def __call__(self, p0: int, p1: Exception) -> None: ...
def handler(on_error: ErrorHandler): ...If anything, having type signatures like that are a good thing! If you think they are too complicated/ugly or driving you crazy, then you have an incentive to improve them. In many languages, callbacks are now considered bad style and that's good! Hiding the type signature does not make the problem go away, you just move it into the future where it will bite you even more.
No type signature? Or documentation in another file somewhere else guaranteed to be out of sync, difficult to find and not enforced by the compiler? No thanks to either of them.