I know that this is a resolved question, but wouldn't Huet's Zipper
also work for this
On Oct 20, 2007, at 5:26 PM, Alfonso Acosta wrote:
On 10/20/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
I am not a monad-expect, so I may be wrong, but wouldn't a writer
monad
be more appropriate?
I'm writing some code where I take an expression tree and transform it
into another equivilent one.
Now it's moderately easy to write the code that does the transformation.
But what I *really* want is to print out the transformation *sequence*.
This appears to be much more awkward.
What I
How about using a state monad as a logger?
You store the transformation sequence in the state while processing
the tree, then you simply retrieve the state and print it out.
Your transformation function should change to
import Control.Monad.State
data Log = ... -- to be defined
type
Alfonso Acosta wrote:
How about using a state monad as a logger?
You store the transformation sequence in the state while processing
the tree, then you simply retrieve the state and print it out.
Mmm... that could work... I'll investigate.
Thanks.
Andrew Coppin wrote:
I'm writing some code where I take an expression tree and transform it
into another equivilent one.
Now it's moderately easy to write the code that does the transformation.
But what I *really* want is to print out the transformation *sequence*.
This appears to be much
Hi Alfonso Andrew
Alfonso Acosta wrote:
How about using a state monad as a logger?
I am not a monad-expect, so I may be wrong, but wouldn't a writer monad
be more appropriate? After all, it is just used for logging the
intermediate results, not to keep read/write state. In other words, we
just
On 10/20/07, Andrew Coppin [EMAIL PROTECTED] wrote:
I'm writing some code where I take an expression tree and transform it
into another equivilent one.
Now it's moderately easy to write the code that does the transformation.
But what I *really* want is to print out the transformation
Twan van Laarhoven wrote:
How about:
transform ... =
(transform sub1 = put back into main expression)
++ (transform sub2 = put back into main expression)
Or something to that effect? Or maybe
transform ... = do
sub' - transform sub1 ++ transform sub2
put back
Brent Yorgey wrote:
Hmm... I'm having trouble understanding exactly what you want. In
particular, I don't understand what this statement:
But what I *really* want is to print out the transformation *sequence*.
has to do with the pseudocode that you exhibit later. Could you
perhaps
On Oct 20, 2007, at 15:05 , Andrew Coppin wrote:
I can quite happily construct a program which, given the first
line, yields the last line. But getting it to print all the
intermediate steps is harder. And, like I said, when something is
hard in Haskell, it usually means you're doing it
On Sat, Oct 20, 2007 at 08:05:37PM +0100, Andrew Coppin wrote:
Brent Yorgey wrote:
Hmm... I'm having trouble understanding exactly what you want. In
particular, I don't understand what this statement:
But what I *really* want is to print out the transformation *sequence*.
has to do with
Stefan O'Rear wrote:
On Sat, Oct 20, 2007 at 08:05:37PM +0100, Andrew Coppin wrote:
I want to construct a program that prints out something like this:
[\fx - f(fx)]
[\f - [\x - f(fx)]]
[\f - S[\x - f][\x - fx]]
[\f - S(Kf)[\x - fx]]
[\f - S(Kf)f]
S[\f - S(Kf)][\f - f]
S(S[\f - S][\f -
On 10/20/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
I am not a monad-expect, so I may be wrong, but wouldn't a writer monad
be more appropriate?
You are at least more monad-expert than myself . I knew the existence
of the writer monad but not really how it works. After checking its
13 matches
Mail list logo