Quoth Ivan Lazar Miljenovic <ivan.miljenovic@xxxxxxxxx>,
> Whilst the Either type isn't officially used for
> errors, that is how it is usually treated in Haskell with the consensus
> that Left = failure and Right = success (note that due to how its
> defined it also has to be this way for Either's Monad instance to
I'm glad you mentioned that, I was going to mention how natural it
would seem for Either to be an instance of Monad, given that it is
used as you say by consensus for errors ... but something seems to
be wrong with my libraries:
No instance for (Monad (Either [Char]))
arising from a use of `return' at except.hs:25:24-29
add an instance declaration for (Monad (Either [Char]))
So, I understand how to make a Monad instance, and I guess your
point stands (as demonstrated by the expected type of (Either String)),
but it's funny that Either is understood to have a Monad instance
even though that's only implied, and not supplied.
I think though that you can't have it both ways - Either
"Either is universally understood to be for success/failure-with-error"
"Either does not imply any meaning, it represents any A/B option pair"
We're really stuck with the latter - that's why, as explained
early in this thread, the names are essentially value free
(it's Left/Right, not Wrong/Right.) Since Either doesn't imply
meaning, its use with errors presents an ambiguity that has to
be resolved by the reader - something I have to comprehend if
I read your code, and it might indeed be easier to read code
that uses a type that, though unique to the code, has names that
reflect its meaning.
Donn Cave, donn@xxxxxxxxxxx
Haskell-Cafe mailing list