2011/3/29 Kevin Wright <[email protected]>

>
>
>> In no time, you will find yourself with dozen of methods calling each
>> other and each of them returning an array of Either objects. Each code
>> handling such Either object will have to decide whether they just want to
>> ignore the error case or handle it. This is not just a nightmare to
>> maintain, it's also a nightmare to read and to extend.
>>
>
> No... The whole point is that they're monads.  You can map over Eithers
> happily ignoring one or another of the possibilities.
>

I understand that, but just because you can apply the operation you need on
it without caring whether it's an error not doesn't solve the main problem.
You are so obsessed with the façade that monads give you here that you are
missing the sheer impracticality of mixing errors in success on the same
channel.

Besides, what you are calling a Monad is more like the null object pattern,
which I saw described for the first time in the GoF book, I believe (around
1994).



>
> Nicely summarised here:
> http://babyloncandle.blogspot.com/2010/03/scalas-alternatives-to-exceptions.html
> (scroll down to the example with the for-comprehensions)
>

Ugh, that's some pretty ugly code there.


> and therein lies the problem, that separate channel causes absolute havoc
> if you need to e.g. perform the same operation on members of a collection
> and handle exceptions from each one independently.  You have have multiple
> channels for the results of processing each item, but are forced to just a
> single channel to handle errors from all of them.
>

No, you have one channel where you are guaranteed to be dealing with real
objects (no nulls, no partially constructed objects) and one that contains
errors. Whether you want the error channel to contain just one error or a
collection of all the things that went wrong is an implementation detail,
but the important part is that these two channels are completely separated.

Anyway, I can't believe I'm arguing for the benefit of exceptions, can we
get back to 21st century discussions? This is getting tiresome.

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to