
16 Jan
2012
16 Jan
'12
8:41 a.m.
Hi all, I would like to propose adding the following function to Control.Monad to complement the `void` function: voidM :: Monad m => m a -> m () voidM m = m >> return () This function would be used to prevent warnings like Warning: A do-notation statement discarded a result of type Int. Suppress this warning by saying "_ <- bar", or by using the flag -fno-warn-unused-do-bind The (rather contrived) code below was used to generate the warning above: foo :: IO () foo = do bar return () bar :: IO Int bar = return 1 Using `voidM`, we can rewrite `foo` as such: foo' :: IO () foo' = do voidM bar return () after which no warning will be generated by GHC. Jurriën