I'd recommend taking a look at the implementation of dotrace (last function in the file):
http://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/trace.clj It let-binds a wrapper function for each of the functions you want to trace, so that within the context of the traced expression those function calls resolve to the wrapped versions rather than the originals. I'm not a monad expert, but as far as I understand they are implemented in a similar fashion. The original functions of your computation get wrapped so that the monad infrastructure can carry along extra values and/or operate on return values. That said, I don't really think of either tracing or monads as a way to change the semantics of your functions. Instead the functions stay the same while the machinery around them is modified. -Jeff On Sep 20, 2:11 pm, Jacek Laskowski <ja...@laskowski.net.pl> wrote: > On Mon, Sep 20, 2010 at 1:41 AM, Mike Meyer > > <mwm-keyword-googlegroups.620...@mired.org> wrote: > > It already exists - it's clojure.contrib.trace (or was - it may have > > moved in 1.2). Usage is (dotrace [foo ...] (expression)) and it traces > > the foo and ... functions while evaluating (expression). > > While we're at it, let me ask you a question about monads (which I'm > trying to get my head around for a while with a little if any success) > - does dotrace do the work monads are better suited for? May I say > that dotrace as a macro does at compile time what monads would do at > runtime? I might be mistaken, but dotrace is about changing semantics > of function calls and so are monads, aren't they? > > Jacek > > -- > Jacek Laskowski > Notatnik Projektanta Java EE -http://jaceklaskowski.pl -- 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