On 07.01.2010, at 01:56, Steven E. Harris wrote:
I'm interested in what you mean by "composite computation", because I
think it's hinting at some concept for monads that I missed. If, as
you
say, executing the function immediately is not acceptable behavior,
then
I infer that the goal is to delay evaluation of the monadic function
'f'
until someone finally passes in a "real" continuation as, say, by the
`run-cont' function. Is that right?
Right. Consider the following simple example:
(domonad cont-m
[x (m-result 1)
y (m-result 2)]
(+ x y))
Its result is a function that, when called with a continuation
argument, calls the continuation with the argument 3. This implies
that nothing at all is executed when the monadic composition happens.
All real execution is delayed until the composite function is called.
If so, is it the case with all or most monads that the bind operator
is
not meant to actually perform computation on the spot, but rather to
compose a delayed computation, or is this delaying particular to the
continuation monad?
No. The state and continuation monads behave like that, but the
sequence and maybe monads do not. This is not as arbitrary as it may
seem to be, as there is a simple rule: When the monadic values are
functions representing computations, monadic composition yields a new
function but doesn't execute anything. When the monadic values
represent results of computations, then monadic composition implies
execution of the computational steps.
Konrad.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en