3 ms·
> since the type of a variable can change at runtime. Can you give an example of that? Mypy catches this: def addsome(val: int) -> int: val += 1.1
by neolog 5y ago
> since the type of a variable can change at runtime.
Can you give an example of that? Mypy catches this:
def addsome(val: int) -> int:
val += 1.1 # tmp.py:2: error: Incompatible types in assignment (expression has type "float", variable has type "int")
return val
I'm sure there are cases where it doesn't notice, but afaik those are considered bugs. Doesn't Haskell have bugs?
- MillenialMan 5y agoProvided you don't circumvent strict typing, no, Haskell does not have typing bugs. Or rather, it has so few that you can functionally behave as if the type checking is flawless. One of the main benefits of strict typing is that confidence - 95% coverage is helpful, but it's just helpful. 100% coverage allows you to program completely differently. It's also static - does Mypy throw that error when that program is statically analysed, or at runtime?
- neolog 5y agoMypy shows that error statically.