Don't have time to go in depth on an explanation. But remember that m-
bind must work with m-result according to the 3 monadic laws. This
constrains what it can do. Don't know if you saw, but I did a whole
tutorial on the continuation monad. It's at:

http://intensivesystems.net/tutorials/cont_m.html

Jim

Steven E. Harris wrote:
> In clojure.contrib.monads, there's a monad defined called "cont-m" to
> model continuations. Its bind operator -- `m-bind` -- is defined as
> follows:
>
> ,----
> | (fn m-bind-cont [mv f]
> |   (fn [c]
> |     (mv (fn [v] ((f v) c)))))
> `----
>
> I'm curious why there's an extra delaying wrapper function there. The
> outermost `fn' form taking the argument "c" as a continuation looks like
> it serves only to delay evaluation of the remaining forms.
>
> The parameter "mv" is a monadic value which, for the continuation monad,
> is a function accepting a single continuation argument. The parameter
> "f" is a monadic function which, again, for the continuation monad, is a
> function accepting a value offered by a continuation and returning a
> monadic value -- another function accepting a single continuation
> argument.
>
> If all of that is true, then the form
>
> ,----
> | (f v)
> `----
>
> should evaluate to a monadic value and be suitable as a return value
> from `m-bind'. In short, why is this not an acceptable implementation?
>
> ,----
> | (fn m-bind-cont [mv f]
> |   (mv (fn [v] (f v))))
> `----
>
> --
> Steven E. Harris

-- 
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

Reply via email to