[Haskell-cafe] Re: The danger of Monad ((->) r)
Isaac Dupree
isaacdupree at charter.net
Fri May 25 18:51:05 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Conal Elliott wrote:
> -- Standard instance: applicative functor applied to monoid
> instance Monoid a => Monoid (IO a) where
> mempty = pure mempty
> mappend = (*>)
>
> On second thought, I don't really like (*>), since it's easy to
> accidentally
> discard a useful value. (I dislike (>>) for the same reason.)
Exactly; because they don't make monoids, because (x `mappend` mempty)
isn't (x), so mempty isn't a right-identity of mappend, so the instance
doesn't follow the monoid laws.
Isaac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGV2hZHgcxvIWYTTURAjlsAJ0fyUrqYAx09neVi2/FN+sUQobEUACfWAph
2WJwISDe/11pg41lcV80uik=
=SYQB
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe
mailing list