I converted the code in the paper "Monadic Parsing in Haskell" to
Clojure. Both m-plus and m-seq are used to combine lists of parsers.
m-plus is used to build a parser that executes each parser in the list
until one succeeds. m-seq is used to build a parser that executes all
the parsers in the l
Jim,
> As long as your breaking things in monads, what would you think of
> changing m-seq to this.
...
> so that it doesn't accept a list of monadic values but instead lets
> you call it with any number of mv's.
>
> Instead of:
>
> (m-seq [mv1 mv2 mv3])
>
> you would write
>
> (m-seq mv1 mv2 mv3
Konrad,
As long as your breaking things in monads, what would you think of
changing m-seq to this.
(defmonadfn m-seq
"'Executes' the monadic values in ms and returns a sequence of the
basic values contained in them."
[& ms]
(reduce (fn [q p]
(m-bind p (fn [x]
On 18.02.2009, at 22:40, jim wrote:
> Here's an updated state-m monad transformer. I dropped my CA in the
> mail today. I figure if I post a snippet of code to the list, it's
> public domain, so do with it as you wish. Or wait till Rich gets my
> CA.
Thanks! It's in my working copy of the mo
I like that. It makes it clear what is a monad, and what is not.
On Wed, Feb 18, 2009 at 3:24 AM, Konrad Hinsen wrote:
>
> The latest Clojure version broke many of my code by introducing the
> function sequence whose name collided with my sequence monad. So I
> decided that since now is the time
Konrad,
Here's an updated state-m monad transformer. I dropped my CA in the
mail today. I figure if I post a snippet of code to the list, it's
public domain, so do with it as you wish. Or wait till Rich gets my
CA.
(defn state-t [m]
(monad [m-result (with-monad m
(fn [