Dan Weston wrote:
> Can you elaborate on why Const is not a monad?
> 
> return x = Const x
> fmap f (Const x) = Const (f x)
> join (Const (Const x)) = Const x
> 

This is not  Const , this is the  Identity  monad.

The real  Const  looks like this:

   newtype Const b a = Const b

   instance Monoid b => Applicative (Const b) where
        pure x = Const mempty
        (Const b) <*> (Const b') = Const (b `mappend` b')

The only possible monad instance would be

   return x = Const mempty
   fmap f (Const b) = Const b
   join (Const b)   = Const b

but that's not just  ()  turned into a monad.


Regards,
apfelmus

--
http://apfelmus.nfshost.com

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to