FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

Dan Weston westondan at imageworks.com
Wed Aug 1 19:05:03 EDT 2007


I knew someone was going to catch me wandering into the deep end of the 
pool!

Having read large parts of your blog, I would never presume to tell you 
anything about Haskell or category theory, but what the hell...

 > I mostly sympathise with your rant, but I think you need to be clearer
 > about what exactly is concatenated. In general you can't concatenate
 > Monads. What you *can* concatenate are Kleisli arrows (ie. things of
 > type Monad m => a -> m b). You can also apply Kleisli arrows to
 > Monads, and that's what >>= does.
 >
 > I feel that talking about Monads without Kleisli arrows is like
 > talking about category theory without arrows, or at least sets without
 > functions. In each case, without the latter, the former is more or
 > less useless.

OK, I'll be clearer. I did actually mean Kleisli arrows, though I 
disagree about your statement about concatenating monad instances and 
claims of "useless":

Prelude> print "Hello" >> return 3
"Hello"
3

Granted, >> is not as "general" as >>=, so combining one monad instance 
with another is not as "general" as with a Kleisli arrow: concatenating 
degenerates to simple sequencing.

Sequencing print statements is more rather than less useless to many 
people, but I see your point. Actually, you have made my point! :)

The forgetful action of Kleisli arrows acting on a monad (or conversely 
the free algebra of a monad as a subspace of Kleisli arrows) is to my 
understanding intimately connected with the specialness of the IO monad. 
It is the continuous nature of Haskell monads that gives non-IO monads 
value. So I guess my rant really was about Kleisli arrows not all being 
forgetful functors, used only for their sequencing effect. It just 
sounded too hard to pull that argument off without reinforcing the myth 
that you need to know category theory to have a rant about Haskell 
tutorials.

 > Also, I'm having a terminological difficulty that maybe someone can 
help with:
 >
 > 'Monad' is a type class.

Actually I thought it was a type class constructor. The monad Monad m => 
m a is continuous in its instance type a, which is important in 
establishing the relationship between >>= and >>. The Haskell type 'IO 
()' is a monad instance that is also isomorphic to the discrete trivial 
monad, but that is not a Haskell Monad capital-M.

I used the term "instance" because the type IO () is an instance of the 
typeclass IO, not for any more profound reason.

Forgive the display of wanton ignorance above. After all, isn't that 
what ranting is all about?

Dan Weston

Dan Piponi wrote:
> On 8/1/07, Dan Weston <westondan at imageworks.com> wrote:
>> The moral of the story is that monads are less than meets the eye. You
>> can create them and concatenate them
> 
> I mostly sympathise with your rant, but I think you need to be clearer
> about what exactly is concatenated. In general you can't concatenate
> Monads. What you *can* concatenate are Kleisli arrows (ie. things of
> type Monad m => a -> m b). You can also apply Kleisli arrows to
> Monads, and that's what >>= does.
> 
> I feel that talking about Monads without Kleisli arrows is like
> talking about category theory without arrows, or at least sets without
> functions. In each case, without the latter, the former is more or
> less useless.
> 
> Also, I'm having a terminological difficulty that maybe someone can help with:
> 
> 'Monad' is a type class.
> 
> So what's 'IO'? Is the correct terminology 'instance' as in 'IO is an
> instance of Monad'. I consider 'IO' to be 'a monad' as that fits with
> mathematical terminology. But what about an actual object of type 'IO
> Int', say? Some people have been loosely calling such an object 'a
> monad'. That doesn't seem quite right. Maybe it's 'an instance of IO
> Int', though that's stretching the word 'instance' to meaning two
> different things. And if an object of type IO Int is in instance of IO
> Int, is it reasonable to also call it an 'instance of IO', or even 'an
> instance of Monad'? I'm sure there are proper words for all these
> things if someone fills me in.
> --
> Dan
> _______________________________________________
> 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