[Haskell-cafe] Type classes

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue May 28 17:17:35 CEST 2013


On Tue, May 28, 2013 at 04:42:35PM +0200, Johannes Gerer wrote:
> By the same argument, could'nt I say, that any type class (call it
> AnyClass) can do everything a Monad can:
> 
> instance AnyClass m => Monad (Cokleilsi m ())

That doesn't say that AnyClass can do anything a Monad can.  "AnyClass m =>
Monad m" would say that, but that's not what you've got.

What you've got is that "Cokleisli m ()" i.e. "(->) m ()" is a Monad for any
"m".  This is not surprising.  The implementation is the same as the Reader
monad.

Check out the instance implementations for "Monad (Reader r)" and "Monad
(CoKleisli w a)".  You will find they are the same.

    http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/doc/html/src/Control-Monad-Reader.html#Reader
    http://hackage.haskell.org/packages/archive/comonad/3.0.0.2/doc/html/src/Control-Comonad.html#Cokleisli

Tom



More information about the Haskell-Cafe mailing list