On May 11, 2:40 am, Konrad Hinsen <konrad.hin...@laposte.net> wrote:
> On 11.05.2009, at 03:00, Rich Hickey wrote:
>
> > Could you explain a bit why you needed to do this? I'm a bit concerned
> > about libraries requiring symbol-macros.
>
> Here is a simplified view of how my monad library works. Each monad
> is an object that contains the definition of a few functions. Other
> monadic functions are defined in terms of these basic functions.
> Monads are applied by surrounding the code depending on the monadic
> functions by (with-monad m ...) form, which is a macro that expands into
>
>         (let [m-result ... m-bind ... m-zero ... m-plus ...] ...)
>
> The problem now is to define the monadic functions such that they
> depend on the monad without having it as an explicit argument. My
> initial solution was to first define a function that takes the four
> basic functions as explicit arguments:
>
>         (defn --m-foo-- [m-result m-bind m-zero m-plus x y]  (m-plus x y))
>
> and then a macro that provides the desired interface:
>
>         (defmacro m-foo [x y]  (--m-foo-- m-result m-bind m-zero m-plus x y))
>
> This works fine for direct calls to m-foo, but since m-foo is not a
> proper function, it cannot be passed as an argument to other
> functions. The current implementation therefore uses symbol macros,
>
>         (defsymbolmacro m-foo (partial --m-foo-- m-result m-bind m-zero m-
> plus))
>
> removing all restrictions on the use of monadic functions. My recent
> exchange with samppi concerns just a small detail: I had forgotten to
> add symbol macros for the four basic monad functions.
>

I have to admit to not having had time to go through your monad code
in detail, but I'd like to ask the general question:

Why not use dynamic binding in a Clojure implementation of monads?

Rich

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