[Haskell-cafe] Type classes

Johannes Gerer kuerzn at gmail.com
Tue May 28 17:21:58 CEST 2013


That makes sense. But why does

instance Monad m => ArrowApply (Kleisli m)

show that a Monad can do anything an ArrowApply can (and the two are
thus equivalent)?

On Tue, May 28, 2013 at 5:17 PM, Tom Ellis
<tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list