logoalt Hacker News

dwatttttlast Wednesday at 7:06 AM2 repliesview on HN

> Either way, you didn't annotate the code so it's kind of pointless to discuss.

There are several literals in that code snippet; I could annotate them with their types, and this code would still be exactly as it is. You asked why there are competing type checkers, and the fact that the language is only optionally typed means ambiguity like that example exists, and should be a warning/bug/allowed; choose the type checker that most closely matches the semantics you want to impose.


Replies

dragonwriterlast Wednesday at 8:32 AM

> There are several literals in that code snippet; I could annotate them with their types, and this code would still be exactly as it is.

Well, no, there is one literal that has an ambiguous type, and if you annotated its type, it would resolve entirely the question of what a typechecker should say; literally the entire reason it is an open question is because that one literal is not annotated.

show 1 reply
MangoToupelast Wednesday at 5:00 PM

> I could annotate them with their types, and this code would still be exactly as it is.

Well, no, you didn't. Because it's not clear whether the list is a list of value or a list of values of a distinct type. And there are many other ways you could quibble with this statement.