4 ms·
> Otherwise, when your program throws a NullPointerException you'll have no way to know where that null originated from. Actually, it's the other way around: N
by laureny 13y ago
> Otherwise, when your program throws a NullPointerException you'll have no way to know where that null originated from.
Actually, it's the other way around: NullPointerExceptions are typically trivial to track down.
Finding out at what part of a monadic computation the return of a function put a None when there should have been a Some is much more tricky.
- tome 13y ago> Finding out at what part of a monadic computation the return of a function put a None when there should have been a Some is much more tricky. The point is you don't have to, because you don't use Maybe where you know statically that there can't be Nothing!
- laureny 13y agoThat's the theory. In practice, your code is clearer if you use Maybe's all along the composition path, otherwise you spend your time unboxing/lifting values.
- chongli 13y agoFinding out at what part of a monadic computation the return of a function put a None when there should have been a Some is much more tricky. This is where Either comes in handy. Either allows you to attach extra information to the error condition (such as a String). This lets you have the same properties of Maybe but with more information when you need to disambiguate.