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)]
                               (when (not= nil result)
                               ((func (first result)) (second
result))))))

           m-zero (fn [strn]
                      nil)

           m-plus (fn [& parsers]
                      (fn [strn]
                          (first
                                (drop-while nil?
                                            (map #(% strn)
parsers)))))])

I explain it in:

http://intensivesystems.net/tutorials/monads_101.html

What kind of parsing are you doing?

Jim

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to