Fwd: Monads and pedagogy (Functions with side-effects?)

Oops...meant to send this to the list, too.
--- Greg Woodhouse
Date: Wed, 21 Dec 2005 09:42:44 -0800 (PST) From: Greg Woodhouse
Subject: Monads and pedagogy (Functions with side-effects?) To: David Barton --- David Barton
wrote: Wolfgang Jeltsch writes: ----- Original Message -----
Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg:
[...]
Monads, I believe, can be just thought of as containers for state.
I would say that you are talking especially about the I/O monad here. A monad as such is a rather general concept like a group is in algebra.
While this is correct, I'm afraid that for most of us it is a flavorless answer. I wish I had the mathematical mind that made the word "group" in this context instantly intuitively recognizable, but I don't.
Groups are actually relatively intuitive structures, representing (no pun intended) the symmetries of some type of object. So, in teaching group theory it is easy to immediately provide a number of easy to grasp examples: the symmetric group (any kind of rearrangement), the cyclic group (cyclic permutation), dihedral group (geometric symmetries of a "square"), SL(n, R) ("area preserving" linear transformations), SO(n, R) (transformation preserving angles), Isom(M) (all geomteric motions of an object so that in the end it occupies the same "space" without any stretching or other deformation), etc., etc.
Rings are a little more tricky, but R[x] (polynomials over R) is the universal example, with homomorphic images like Z[i] just being "polynomials in i" where you "reduce" according to i^2 = -1, and so on. Matrices over a ring give you the prototypical example of a module. I could go on, but the point is that in abstract algebra it is usually easy to provide simple intuitive examples of the structures illustrating most of the basic properties of the category. (Okay, okay, topoi and coherent sheaves may be an exception! But even then, analytic functions go a long way.)
With monads, it is not hard to give a formal definition, just as is the case with groups, but much harder (for me, anyway) to find a simple intuitive set of examples that capture the essence of monads in such a way that the definition is obvious. Think about it: If groups are just symmetries, then "doing nothing" is clearly a symmetry (1), "doing nothing" before or after a symmetry doesn't change anything. "Undoing" a symmetry gives you an inverse. Associativity is less obvious, unless you think of groups realized as permutations of a set, so that the group product just becomes function composition.
=== Gregory Woodhouse
"Interaction is the mind-body problem of computing." --Philip L. Wadler
participants (1)
-
Greg Woodhouse