Hacker News new | past | comments | ask | show | jobs | submit login

I think that's taking things a bit far.

The compiler will make sure you are returning an Int, but it has no ability to make sure it is the right Int.

Or, in more practical terms, the type system has the ability to make sure I'm returning a Reader MyConfig Int. This guarantees that a) all configuration parameters come from a single known location, b) no side effects and c) the output is an Int. But I still need unit tests to make sure the result is correct.




Ints and strings are a poor example because they have a very large domain. These features are much more useful when you're talking about more complex data structures, like the intermediate representation in a compiler. I think typechecking is most useful with complex data structures, anyway - their invariants can be built into the type.

There are other languages with the ability to constrain types to specific ranges, etc. (without having to define e.g. RInt of One | Two | Three | Four | ...), but they're still pretty obscure.




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

Search: