Newbie question about Haskell skills progress

Having only a couple of days of practice programming Haskell (but having read lots of books and docs), I find myself writing very explicit low level code using inner "aux" functions (accumulators and loops). Then I force myself to revise the code, replacing these aux functions with suitable higher-order functions from the library. However, I would like to use these higher order functions right away, without using low-level aux constructs, which is most likely caused by my very long history of imperative programming. Is this the "normal" way of progressing in Haskell, or should I consider a different approach? Thanks, Peter

On 31/07/07, peterv
Having only a couple of days of practice programming Haskell (but having read lots of books and docs), I find myself writing very explicit low level code using inner "aux" functions (accumulators and loops). Then I force myself to revise the code, replacing these aux functions with suitable higher-order functions from the library. However, I would like to use these higher order functions right away, without using low-level aux constructs, which is most likely caused by my very long history of imperative programming…
Seems sensible to me! It'll come with time, I'm sure. I often find it useful to think about general abstractions and then choose an approach from there: - many-to-one -> fold - many-to-many -> map - one-to-many -> unfold And so on in a similar fashion. This might mean you do something stupid (as witnessed by my most recent visit to Haskell Cafe, where I said some very silly things [1] but also got some enormously clever/silly pointers [2]). But it's all part of life's rich pattern, and I can't think of a nicer place to make a fool of one's self than in this community. [1]: http://www.haskell.org/pipermail/haskell-cafe/2007-July/029274.html [2]: http://www.haskell.org/pipermail/haskell-cafe/2007-July/029285.html
Is this the "normal" way of progressing in Haskell, or should I consider a different approach?
There are probably some people here who were imbibing type theory and lambda calculus with their mammy's milk... but for the rest of us, it's just one small step at a time. Cheers D.

Having only a couple of days of practice programming Haskell (but having read lots of books and docs), I find myself writing very explicit low level code using inner "aux" functions (accumulators and loops). Then I force myself to revise the code, replacing these aux functions with suitable higher-order functions from the library. However, I would like to use
peterv wrote: these
higher order functions right away, without using low-level aux constructs, which is most likely caused by my very long history of imperative programming.
Is this the "normal" way of progressing in Haskell, or should I consider a different approach?
I can't really judge whether a different approch might be better, but I learned, and still learn it, in a very similar same way. I think it just takes a while until one can see an abstraction right away, that is, even before one starts writing anything down. I am not nearly as far as I'd like to be in this regard, but I can now 'see' folds and maps quite early in the process (still having some difficulty to 'see' an unfold, though). More and more often I watch myself immediately writing down pipelines of (often not yet implemented) functions, combined with dots, maps, etc, something I wouldn't have done a few months ago. Still, most code I write goes through multiple refactorings, searching through libary docs (for some function that might already implement the pattern), re-thinking and then re-designing my data structures, and so on, before I have the feeling that the solution is acceptable and I can move forward. While this process can be frustrating in the beginning (when you follow one or the other blind alley, for instance), in the end the result is extremely rewarding: I regularly end up with code that is 5 times smaller than what I started with, looks deceptively simple, almost trivial (although that may be subjective, caused by the my advanced understanding of the problem), and seeing how in the end everything nicely falls into place gives me the sheer pleasure. Cheers Ben

bf3:
Having only a couple of days of practice programming Haskell (but having read lots of books and docs), I find myself writing very explicit low level code using inner "aux" functions (accumulators and loops). Then I force myself to revise the code, replacing these aux functions with suitable higher-order functions from the library. However, I would like to use these higher order functions right away, without using low-level aux constructs, which is most likely caused by my very long history of imperative programming...
Is this the "normal" way of progressing in Haskell, or should I consider a different approach?
I think this is normal: you start with manual loops, and you learn the names for each loop form over time, using the combinator forms once you're familiar with them. Thanks for the insight! -- Don
participants (4)
-
Benjamin Franksen
-
dons@cse.unsw.edu.au
-
Dougal Stanton
-
peterv