[Haskell-cafe] Re: Newbie question about Haskell skills progress

Benjamin Franksen benjamin.franksen at bessy.de
Tue Jul 31 21:35:38 EDT 2007


peterv wrote:
> 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 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



More information about the Haskell-Cafe mailing list