Re: Monad problems: finding an m-zero

2009-11-24 Thread samppi
The original reason is that I need to be able to transfer certain certain metadata such as memoization tables between failure results in m-plus. I'm writing a PEG-type parser that hopefully can support left- recursion without any conversion to right-recursive rules. I'm using metadata because I don

Re: Monad problems: finding an m-zero

2009-11-24 Thread Konrad Hinsen
On 21 Nov 2009, at 06:31, samppi wrote: > And no matter what I do, I can't fulfill that second axiom. Has anyone > created this type of monad before? It seems like it should be a common > pattern: exactly like (state-t maybe-m), only failures are vector > pairs too. One problem I see in your ques

Re: Monad problems: finding an m-zero

2009-11-23 Thread jim
Konrad, Glad to see you're still around doing monads in Clojure. :) Jim -- 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

Re: Monad problems: finding an m-zero

2009-11-23 Thread Konrad Hinsen
On 22 Nov 2009, at 22:10, John Harrop wrote: > Is there an explanation of monads out there that doesn't require the > reader to know Haskell to understand it? One that's generic to any > FP-capable language? Nothing I know of; you need some syntax if only for the examples. Moreover, there a

Re: Monad problems: finding an m-zero

2009-11-23 Thread Konrad Hinsen
On 22 Nov 2009, at 22:06, samppi wrote: > Yes, I see. I'm going to guess that the parser-m that I give above has > no possible m-zero, so I think I'll have to rethink how I'm going to > approach this problem. I probably am going to just define failure in > another way. (The reason why I can't use

Re: Monad problems: finding an m-zero

2009-11-22 Thread jim
I wrote one specifically for monads in Clojure. http://intensivesystems.net/tutorials/monads_101.html There's also a second part. Also, Konrad Hinson wrote one: http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-1 it's in 4 parts, I believe. John Harrop wrote: > On

Re: Monad problems: finding an m-zero

2009-11-22 Thread John Harrop
On Sun, Nov 22, 2009 at 4:25 PM, Martin DeMello wrote: > On Mon, Nov 23, 2009 at 2:40 AM, John Harrop wrote: > > Is there an explanation of monads out there that doesn't require the > reader > > to know Haskell to understand it? One that's generic to any FP-capable > > language? > > Most of them

Re: Monad problems: finding an m-zero

2009-11-22 Thread Martin DeMello
On Mon, Nov 23, 2009 at 2:40 AM, John Harrop wrote: > Is there an explanation of monads out there that doesn't require the reader > to know Haskell to understand it? One that's generic to any FP-capable > language? Most of them use the concrete syntax of *some* language. But this is a good non-ha

Re: Monad problems: finding an m-zero

2009-11-22 Thread John Harrop
Is there an explanation of monads out there that doesn't require the reader to know Haskell to understand it? One that's generic to any FP-capable language? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Monad problems: finding an m-zero

2009-11-22 Thread samppi
Yes, I see. I'm going to guess that the parser-m that I give above has no possible m-zero, so I think I'll have to rethink how I'm going to approach this problem. I probably am going to just define failure in another way. (The reason why I can't use nil is because I need to store metadata on the ob

Re: Monad problems: finding an m-zero

2009-11-22 Thread jim
Samppi, Good work on figuring that out. It's by working through those kinds of problems that you really learn about monads. It is indeed the case that not all monads have m-zero and m-plus defined for them. The state- m monad is one of those. Not only that, but if you take a look at the state-t mo

Re: Monad problems: finding an m-zero

2009-11-22 Thread samppi
Thanks for the help. After working it out, I just figured out that the reason why the second axiom isn't fulfilled by the m-zero above is this part in m- bind: ((product-fn product) new-state)) product-fn, which in the second axiom's case is (fn [x] m-zero), gets called

Re: Monad problems: finding an m-zero

2009-11-21 Thread jim
Glad you found that tutorial useful. I had to run this morning, so I couldn't really reply. I'll try to read your post more closely tomorrow and see if I can offer any useful insight. Jim -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Monad problems: finding an m-zero

2009-11-21 Thread samppi
Yes, your monad was the first monad that I was talking about—in fact, I followed your tutorial when I was learning about monads, and I used your examples to create an entire parsing library. I believe that it's essentially equivalent to (state-t maybe-m), except that you use list pairs instead of v

Re: Monad problems: finding an m-zero

2009-11-21 Thread jim
Samppi, Here's a parser-m monad I did. (defmonad parser-m [m-result (fn [x] (fn [strn] (list x strn))) m-bind (fn [parser func] (fn [strn] (let [result (parser strn)]

Monad problems: finding an m-zero

2009-11-20 Thread samppi
I'm writing a maybe/state monad using clojure.contrib.monads. I've gotten by fine with using just (state-t maybe-m), but now I need different behavior: I need a monad that behaves precisely like (state-t maybe-m), except that when a monadic value mv is called on a state s and fails, (mv s) return