On 19.04.2009, at 04:04, jim wrote: > Love your monad library, but somethings always bothered me. The monad > functions like m-seq, m-lift, etc. were macros so they couldn't be > applied, passed as parameters.
True. > While working on an unrelated thing, I had a flash of inspiration and > implemented with-monad as below. This makes all those functions actual > function objects. What do you think? I had something very similar in one of my experimental versions. I abandoned it because I didn't want to fix the list of monad-dependent functions once and for all in the with-monad macro. With my current macro+function approach, any number of monad functions can be defined in any namespace using defmonadfn. Since the first release of the monad library, I added one such function to the library (m-chain), and I have one more in application- specific code. So it appears that the need to define monad functions is not frequent but not completely academic either. The question is thus whether it is more important than being able to use monad functions with apply. There is also another approach I have considered: keep a register of monad functions and have the defmonadfn macro add a function to this register. with-monad would then present all of them as bindings. Such an approach is more complex to implement, but provides a list of real functions that is nevertheless extensible. However, it doesn't play nicely with namespaces, as there would effectively be one global monad function namespace, with the potentially nasty bugs that this implies. In summary, I am still looking for the perfect solution... 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 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 -~----------~----~----~----~------~----~------~--~---