
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 7/1/10 04:27 , Claus Reinke wrote:
The problems start when all of these classes are linked to a single Monad instance, and the 'fail' that has been put in it. So far, I had thought that there was a way to have all common uses of Either compatible with a single 'fail' (representing both non-local returns and empty sums), so I've been arguing to keep a sufficiently general Monad
(a) I would guess not. (b) It strikes me that trying to make one Either do both of these is just wring. Either is a perfectly reasonable sum type; "fail" is not a general attribute of sum types, though. IMO "fail" should be associated with a MonadFailure (which might conceivably be a typeclass which has Either as an implementation; but given the lack of useful information available in its most common usage as part of the "do" machinery, Maybe is just as reasonable an implementation). That said, I'm also not sure if fail maps to the perennially-suggested MonadZero entirely sensibly, btw. Okay, obviously it's related to mzero in some conceptual sense, but it seems to me that it's not related to monoids; instead, it's an exception. The fact that fail is usually implemented as a call to error is symptomatic of this; and treating an exception as a monoid strikes me as a failed abstraction. (On the gripping hand, a MonadFailure typeclass would give people who wanted it the option of doing so. Of course, if you do this then it simply replaces the current question with the question of whether the Either monad should have a MonadFailure instance that is an exception or simply Left, and what happens if someone disagrees... there are no easy answers.) - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwsVkQACgkQIn7hlCsL25VF/QCbBrU+NFx9bEzQva0awdLwZgV5 zyYAoIwemwZUBbLSWEnextXSvjiYR0xG =egxO -----END PGP SIGNATURE-----