>
> I see---also fair enough. How do you implement things like return (for 
> monads) or mempty (for monoids) with protocols? I assume it's the 
> perceived desirability of not having to pass in a parameter 
> corresponding to some concrete monad/monoid/whatever to be able to get 
> the right function for m-return or whatever. A protocol for functors 
> does seem more straightforward to implement. 
>
>
I realized that most of the time I was creating an instance out of another; 
when I wasn't, I could just use a regular constructor, not a monadic one. 
Thus I came to write code like this for the Writer monad and others; notice 
the recurrence of "return this" or mempty working on "this"; here's where 
the protocol and type pay off. (I'll put this lib out before long, hoping I 
can explain it.) At any rate that's the best I've managed so far.

https://gist.github.com/4590513

I asked for self-interested reasons; I have a macro (arguably a silly 
> one) for writing monadic code in a style I prefer to domonad (and 
> would also prefer to your bind macro) [1] and would like to be able to 
> use it with arbitrary things that are monadic. That can't really 
> happen if everyone has his own monad interface. 
>

You did a good great with that macro. It's the most flexible and clean I've 
seen; it really captures the do notation. Your last point is well taken, as 
I'll soon find myself in the same boat with other work.

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