3 ms·
It's a very traditional OO situation: you want a value that know how to handle its error case. Haskell makes it easy to implement that with types. Either you
by lsb 19y ago
It's a very traditional OO situation: you want a value that know how to handle its error case. Haskell makes it easy to implement that with types. Either you can check the integer return value (which your compiler can't verify), you can hack something up similar to it (return all the values in a list, say, and check how long that it), or you can see that a list is also a Monad, and Nothing looks like [] and Just x looks like [x].
In Rails, there's a file whiny_nil.rb, whose sole job is to report errors about people accessing a nil object when they shouldn't be. Using Maybe with pattern matching, coming from Haskell, makes as much sense as implementing Iterator with first-class functions. It looks weird, coming from Visual Basic, but it makes your code readable and short.
- michaelneale 19y agoNo question its a good thing, I am just amused at the "look ma, its a monad" craze going on. But if people are getting excited over FP concepts, thats nothing but a Good Thing (as long as it doesn't turn into a fashion, which will then go away).