Add voidM to Control.Monad
aslatter at gmail.com
Mon Jan 16 17:05:25 CET 2012
2012/1/16 Jurriën Stutterheim <j.stutterheim at me.com>:
> It is indeed intended for monads that have no Functor instance. While one could argue that every monad should have a Functor instance, this is not the case in practice. If, on the other hand, Monad was defined as
> class Functor m => Monad m
> then all would be fine and we would be able to use the current implementation for `void`. A Functor constraint on Monad is an entirely different discussion though.
We would be better off adding Functor instances for the Monads in
question. Then readers wouldn't have to wonder about the difference
between coid and voidM and why one was chosen over the other in a
particular context &c.
> On 16 Jan 2012, at 16:22, Erik Hesselink wrote:
>> 2012/1/16 Simon Hengel <sol at typeful.net>:
>>>> voidM :: Monad m => m a -> m ()
>>>> voidM m = m >> return ()
>>> Is voidM meant to be used with instance of Monad that are no monads, and
>>> hence have no Functor instance (like HtmlM)?
>> You could easily implement a Functor instance for this type, since it
>> would mirror the instance for `Const a` , i.e. only change the type
>> parameter, and otherwise be the identity function.
>>  http://hackage.haskell.org/packages/archive/blaze-html/0.4.3.1/doc/html/Text-Blaze-Internal.html#t:HtmlM
>>  http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Applicative.html#v:Const
> Libraries mailing list
> Libraries at haskell.org
More information about the Libraries