Hacker News new | ask | show | jobs
by dllthomas 4413 days ago
Maybe is more like NaN than an exception, but the nice thing about it as opposed to NaN is that you can isolate the particular failure. Sure, I can check for NaN in my doubles, but my types can't make sure I've checked for it by point X. Running a huge program to solve a problem, and getting back NaN with no explanation, is horrendously obnoxious.
2 comments

Hm, I have the opposite experience. Being able to ignore invalid data every once in a while trumps having a hundred hours of computation cut short by an unexpected exception bringing the whole thing down.
That's why Maybe (without fromJust!) is so nice. You can ignore invalid data for as long as you want, but you can also draw lines and say "it can't have been ignored if flow gets to here". I'm certainly not arguing in favor of exceptions!

Edited to add: That said, I'd rather that 100 hours of computation be cut short than take longer and be equally useless...

I'm really not sure why this was voted down. Anyone have any insight? I don't see anything objectionable, and if I'm missing something I'd like the opportunity to learn...