[Haskell-cafe] Explaining monads
sethg at ropine.com
Tue Aug 14 15:31:40 EDT 2007
Sebastian Sylvan wrote:
> On 14/08/07, Dan Piponi <dpiponi at gmail.com> wrote:
>> If I was one of your students and you said that monads are recipes I
>> would immediately ask you where the monads are in my factorial program
>> regardless of whether you had introduced one or two different
>> analogies for recipes.
> Why would you? I really don't see where you would get that idea? If I
> tell you that a function returns "a fruit", would you ask where the
> fruit in your factorial program is? Probably not. Why would you go off
> and take an analogy for monads and apply it to something completely
> different and still think the analogy holds?
> A function is *not* a recipe in this analogy, it's just a function
> (which you hopefully should've covered by the time you get to monads.
> Monadic values, and *only* monadic values (not functions!) are to be
> viewed as analogous to real world cooking recipes in this analogy.
> Functions shouldn't. If you start mixing things together it will get
> confused, so just don't!
As a mostly-newbie who is working on his own monad tutorial
(bwah-hah-hah), I share Dan's confusion about your analogy.
Teacher: "Monads are like recipes."
Student: "Aren't functions like recipes, too?"
Teacher: "Well, yes, but we're talking about monads now, not functions."
That response doesn't help the student, because the student already
knows about functions, and would probably understand monads a lot better
if he or she knew how monads are *different from* functions.
(Especially since, umm, isn't the ((->) a) data type a monad?)
More information about the Haskell-Cafe