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't want to resort to mutable state refs; even
though it's making my code more complicated, it avoids all the
problems associated with mutable state, especially keeping track of
what changes them where and how.

Right now, I've been doing fine with returning a special "Failure"
object defined by deftype with the failed state's metadata attached to
it. Thank goodness that metadata doesn't affect equality.

On Nov 24, 1:37 am, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
> 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 question is the little word "too". A normal  
> value in the monad (state-t maybe-m) is of the form (fn [state] ...).  
> This is not a vector pair, it's a function.
>
> I am not familiar enough with parsing to understand *why* you want  
> failures represented as vector pairs. It might help you to read the  
> description of Parsec, an elaborate monadic parsing library in Haskell:
>        http://legacy.cs.uu.nl/daan/download/papers/parsec-paper.pdf
> It discusses many "real-world" issues that are usually left out of  
> academic papers on monadic parsing. Perhaps your problem is addressed  
> there as well.
>
> 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
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