Like "Monad" seems to be strongly attached to Haskell
and the writings of Wadler. Never seen "Monad" in CAML code.
Monadic programming is indeed very convenient in Haskell, thanks to
type classes. It is certainly possible in ML, for example,
http://groups.google.com/groups?selm=r8td785em7f.fsf%40chinstrap.CS.Princeton.EDU
You can program monadically even in Unix shell! It is rather
common, actually. Everybody who piped "echo" or "cat" into another
program did monadic programming!
http://pobox.com/~oleg/ftp/Computation/monadic-shell.html
Monads seem to have a parallel in Scheme closures, but I've never
seen anyone make this analogy.
Monadic programming is closely related to "staging." You first write
code (a "compiler") that creates a sequence of "commands". Afterwards,
you execute the commands. The two passes are apparent. The command
executor is a strict evaluator (whereas the evaluator that creates a
"command stream" may be lazy). To achieve such staging in Scheme --
i.e., to create a "command" to be evaluated later -- you typically
wrap it into a closure (or use 'delay' to make it a promise). Any
"instruction" stream can be regarded as a "monad", providing the stream
is associative and the instruction set contains a no-op
"instruction" that can be dropped from the instruction stream with
impunity.
see also the third paragraph of
http://groups.google.com/groups?selm=8d8kd2%24sr4%241%40nnrp1.deja.com
|