Konrad,
Glad to know we were on the same page about monad transformers.
That transformer was indeed a translation from the Haskell
implementation. Using 'with-monad' does clean it up.
I'll have to take a look at your implementation of m-bind.
I did prefer the conciseness and the fact that it
Jim,
you were quicker than me in implementing monad transformers! What I
had in mind is exactly what you did: a monad transformer would be
implemented as a function taking a monad as an argument. That's in
fact why I defined the monad macro in addition to defmonad.
> I did some more work
On Dec 14, 2008, at 23:16, jim wrote:
> Also, I came across set-state and fetch-state being implemented in
> terms of update-state.
Indeed, those are the implementations I had in my first monad
implementation. I replaced them by manually inlining update-state
when I wanted to get rid of mona
Also, I came across set-state and fetch-state being implemented in
terms of update-state.
(defn set-state [s]
(update-state (fn [x] s)))
(defn fetch-state []
(update-state identity))
Jim
--~--~-~--~~~---~--~~
You received this message because
Konrad,
I did some more work from the paper the parser combinator is based
on. From that I built what I think is a state monad transformer:
(defn stateT [m]
(monad [m-result (fn [v]
(fn [s]
((:m-result m) (list v s
m-bind (fn [st
Jim,
> I would make some minor changes in two places. I would write with-
> monad as:
Obviously this is a better version.
> And I would write m-lift as
I like that one as well.
I have uploaded a new version that integrates your improvements.
Another one is that the monad operations are now
Konrad,
I've looked over your monad code and I like it, FWIW.
The macro programming will twist your mind if you don't have
experience writing Lisp style macros, but the resulting syntax seems
pretty clean.
I would make some minor changes in two places. I would write with-
monad as:
(defmacro
Konrad,
I got your code to work by doing the following:
Replaced with-monad with:
(defmacro with-monad
[name & exprs]
(let [bind-sym 'm-bind
result-sym 'm-result
zero-sym 'm-zero
plus-sym 'm-plus]
`(let [~bind-sym (:m-bind ~name)
~result-sym (:m-result ~na
Jim,
thanks for your comments!
> First, the function 'group' that you define seems to be the same as
> Clojure's 'partition' function.
Indeed. I have spent some time checking if something like this exists
already, but I didn't consider "partition" as a name!
> Second, when I tried to load mo
Konrad,
I haven't had a chance to look at this in depth but I did see two
things.
First, the function 'group' that you define seems to be the same as
Clojure's 'partition' function.
Second, when I tried to load monads, I get the following error.
java.lang.ExceptionInInitializerError (monads.cl
A while ago I uploaded an implementation of monads in Clojure to the
group's file section. I have now replaced it by a more or less complete
rewrite. This rewrite was motivated by one serious problem with the
original implementation, plus a number of minor points that I was not
happy with. I have
11 matches
Mail list logo