[Haskell-cafe] Explaining monads
sebastian.sylvan at gmail.com
Tue Aug 14 14:33:14 EDT 2007
On 14/08/07, Dan Piponi <dpiponi at gmail.com> wrote:
> On 8/14/07, Sebastian Sylvan <sebastian.sylvan at gmail.com> wrote:
> > On 14/08/07, Dan Piponi <dpiponi at gmail.com> wrote:
> > > Where do monads come in?
> > Well I would try to distinguish between code that we write to compute
> > values, and values which represent monadic actions when coming up with
> > analogies.
> How would you make that distinction?
How can you *not* make a distinction? If you view source code as
recipes, that's fine, but the *code* doesn't even exist in the
program! You can't pass *code* around (unless you do it as String).
Clearly there's a gulf of difference between the source code ASCII
string that represent the factorial function, and a first class value
that represents an action *in* the language.
> At this point I can imagine
> students immediately thinking that my factorial program is a recipe
> and wondering why it doesn't involve monads.
Well that's easy, don't use the recipe analogy to explain code, use it
for monadic values exclusively, and you avoid the confusion entirely!
I don't think it's that complicated. Monads have a monadic type. They
represent an abstract form of an "action", which can be viewed as an
analogy to real-world cooking recipes. As long as you don't
deliberately confuse things by using the same analogy for two
different things I don't see where confusion would set in.
More information about the Haskell-Cafe