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

I don't understand your example. What does compile-time computed stuff have to do with readInt()?

I get that it might be possible to do that, use a Maybe Maybe T. But it's like an optional<bool> in C++. It can be done, it's just not a good idea. So if you design your system not to allow that in the first place, nothing of value was lost.

If you have specific error cases that you want to communicate, like "what was read from the console didn't parse as an int" as opposed to "the computation didn't find a result", then using the two values "Nothing" and "Just Nothing" as the two distinct values to encode that is not a sound design. Either you have meaning, or you have Nothing. Nothing shouldn't have any meaning attached to it.




> "what was read from the console didn't parse as an int"

I meant what you read from the console can not be computed at compile time.




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

Search: