On 05.01.2010, at 02:23, Steven E. Harris wrote:

> ,----
> | (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.

Exactly. The result of m-bind must be a continuation-accepting  
function again. That's the role of the outer layer (fn [c] ...).

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

It is indeed a value of the right type, but it is not right value that  
represents the composite computation.

> In short, why is this not an acceptable implementation?
>
> ,----
> | (fn m-bind-cont [mv f]
> |   (mv (fn [v] (f v))))
> `----

This version of m-bind would not return the composite computation, but  
rather execute it immediately. This is best seen by the position of  
mv. In your m-bind, mv is called when m-bind is called. That's not the  
desired behaviour.

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to