
Hi, Sugestion: 'when' in Control.Monad is typed as :: Bool -> IO () -> IO (). Why not type it as: :: forall a. => Bool -> IO a -> IO () ? It is easy for 'when' to ignore the result of the first computation, and this would not break existing code, and also save a lot of
return ()s.
Best, Mauríco

Maurício wrote:
? It is easy for 'when' to ignore the result of the first computation, and this would not break existing code, and also save a lot of
return ()s.
As Neil Mitchell pointed out[1], ignoring results implicitly may indicate an error. Perhaps it's cleaner to define ignore m = m >> return () and use it like this: when condition $ ignore doSmth [1]http://neilmitchell.blogspot.com/2008/12/mapm-mapm-and-monadic-statements.ht...

? It is easy for 'when' to ignore the result of the first computation, and this would not break existing code, and also save a lot of
return ()s.
As Neil Mitchell pointed out[1], ignoring results implicitly may indicate an error. Perhaps it's cleaner to define
ignore m = m >> return ()
But isn't exactly that the behavior of (>>)? Anyway, I like the 'ignore' idea. Best, Maurício

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Maurício wrote: |> ignore m = m >> return () | | | But isn't exactly that the behavior of (>>)? ~ ignore :: Monad m => m a -> m () ~ (>>) :: Monad m => m a -> m b -> m b It may also be worth noting that ignore can be generalized to Functor: ~ ignore :: Functor f => f a -> f () ~ ignore x = () <$ x - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkmAdr8ACgkQye5hVyvIUKn64ACeJ9MHwEgbTUUtnqJVuAe+z7bq 1MgAmwQKzvMOj+l/ih+SwrM1myxplLGB =oFVr -----END PGP SIGNATURE-----
participants (3)
-
Gleb Alexeyev
-
Jake McArthur
-
Maurício