Writing a counter function
Mon, 01 Jul 2002 11:10:15 +0100
Mark Carroll <firstname.lastname@example.org> wrote:
> On Sun, 30 Jun 2002, Jon Fairbairn wrote:
> > 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 neede=
> 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 =3D (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=F3n Fairbairn Jon.Fairbairn@cl.cam.ac.u=
31 Chalmers Road email@example.com
Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)