
Mark Carroll wrote:
On Sun, 30 Jun 2002, Jon Fairbairn wrote: (snip)
But there's the rub. It's not beautiful and it doesn't make much sense. I really wish we could get away from the "How do I convert this imperative code snippet into Haskell" questions into "How do I solve this abstract problem?"
The question as originally posed didn't seem like it particularly needed something imperative though.
That largely misses the point. My objection is to the mindset behind the question.
the first bit is very similar to, say,
counter a = (a, \to_add -> counter (a + to_add))
Which looks to me like imperative programming. Indeed, the Monad answer that I posted is imperative programming, it just happens to be done in Haskell. Stepwise transformation of a state is, on some occasions, the right answer to a problem. Unfortunately in this thread we haven't been told what the problem is. The question is of the form "how do I make a hammer?" when a hammer is rarely the most appropriate tool. That's what I'd like to get away from. Jón -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk 31 Chalmers Road jf@cl.cam.ac.uk Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)