Talk:Haskell/Building vocabulary

Opening notes
Nearly two years have passed, but the reorganization of the Beginner's track is finally taking a definite shape :) This particular chapter should have been Apfelmus' baby, as it was the focal point of his restructuring plans. While I followed the spirit of such plans, I am pretty sure he, with his straight-to-the-point approach, would not like so much the fluffy, dialogic form I adopted... Anyway, the final remarks about the remainder of the book might sound a bit hollow, because there is so much left to do in the Practical Haskell trail. The cheat sheet appendix (of which you can see some experiments from 2010) would be an useful development in the general direction of improving that situation. Finally, I must yet again credit Apfelmus, this time for providing inspiration for the "One exhibit" section through this message in the Wikibook mailing list. I almost considered using his example, but instead constructed a similar one with less pre-requisites and more insanity. Nevertheless, it is appropriate to quote his example here.

P.S.: Oh, another thing. Good exercises involving library functions could do wonders in terms of making the approach proposed here work better. If you have an interesting idea, please don't shy away from adding it to the relevant chapter of the book. Perhaps even right here in "Building vocabulary" there could be a few simple exercises requiring light documentation research. (Or maybe these could go to the hierarchical libraries chapters.)

Apfelmus' alternative example (Exhibit #2)
There's nothing wrong with pattern matching. If anything, the problem is this: With pattern matching and recursion, you can define any function on lists. But then, it is also tempting to do exactly that and forgo the vocabulary of functions offered in the Prelude, at the detriment of good Haskell style.

For instance, consider the following task: you are given a file that has a number on each line and you have to add them all up. A direct, recursive, and utterly unintelligible solution would be to go character by character and accumulate the sum

whereas the proper Haskell way to think about this task is

"There be dragons" example
Yes, I know I'm not supposed to stare at it (and I don't intend to run it!) but I noticed there is a then/else pair which does exactly the same stuff, no matter what the value of the testspace c'  condition. \Mike (discuss • contribs) 20:00, 18 July 2014 (UTC)
 * Well spotted, and arguably a good illustration of the overall point. I "fixed" it, lest the readers accuse us of overdramatising :-) Duplode (discuss • contribs) 23:56, 28 June 2015 (UTC)