Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> In Go, you can branch on types at runtime, so in a hypothetical generic Go, you could write something which appears to only ever return its argument, but does something special if the argument is of a particular type

I'm not sure why you bring this up - nearly every language that enables reflection lets you do this, including Haskell[0].

No decidable static type system can ensure correct semantics for all use cases, including even badly written code[1].

[0] And you don't even need reflection to do this, per se; it just makes it more convenient.

[1] One could design a static type system that did, but it would be undecidable.



Parametricity is definitely not impossible to violate, but it's generally morally correct to assume it mostly holds in Haskell. Parametric polymorphism helps make that workable. Further, type classes help to tag code that does use reflection.

You can always get around things, but languages that make a strong commitment to keeping reasoning as a priority are qualitatively different from those that do not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: