Monads for the End?

Why is there no monad instance for Control.Applicative.Const ? Is the following definition correct or violates its monad laws?

 instance Monoid a => Monad (Const a) where return _ = Const mempty (Const x) >>= _ = Const x 

And can you come up with some useful app?

+8
haskell monads
source share
1 answer

It violates the law of left identity : return x >>= f should be the same as fx , but consider fx = Const (x + 1) .

+17
source share

All Articles