Talk:Haskell/Solutions/Lists II

In the answer for scanSum:

scanSum :: [Int] -> [Int] scanSum = scanSum' 0 scanSum' :: Int -> [Int] -> [Int] scanSum' tot [] = [] scanSum' tot (x:xs) = x + tot : scanSum' (x + tot) xs

the second line calls

scanSum' 0

but the signature for scanSum' is

Int -> [Int] -> [Int]

In other words, the list is missing from the call. I can't use scanSum' like this in GHCi. However, scanSum itself works in GHCi, so I assume that the list must be passed implicitly somehow. But this has not yet been discussed in the text. Confusing for a beginner (me).

Wrmorris (discuss • contribs) 20:52, 8 June 2012 (UTC)

Should we streamline the solutions?
Seems that convention of one set of solutions / exercise changed in this section, and some of the provided solutions seem overly complicated. Would it be reasonable to replace with the below? Might also be worth encouraging readers to search group/concat on Hayoo. One problem is I am using the anonymous function notation after googling, but perhaps it makes sense to introduce this earlier for convenience?

--Virgilsamms (discuss • contribs) 01:50, 26 December 2016 (UTC)


 * On the overabundance of solutions: you will see similar things in a few other places along the book. In general, the tidier solution pages were originally written at the same time than the corresponding chapter, while the ones with lots of disparate alternative solutions were mostly written by readers, across a longer time span. In any case, I do agree the solutions to the RLE exercise could do with some streamlining; I will look into it.


 * On your proposed solution and anonymous functions: while anonymous functions are first mentioned in a brief aside in the very next chapter, in general the initial parts of the book tend to take it easy when it comes to introducing syntax variants, to minimise the amount of distractions from the key issues within each chapter. (By the way, for the same reason I am still in two minds about your addition of a hint about  in that exercise in Simple Input and Output.) In any case, anonymous functions can be avoided here, if we wish so, by e.g. using a   block:




 * Duplode (discuss • contribs) 17:36, 27 December 2016 (UTC)


 * Cool, I think your solution strikes the best balance yet of readable terseness without introducing too many concepts. And thanks for sharing some of the guiding principles behind the book--I'll keep that in mind & won't take offense if you discard any changes I make --Virgilsamms (discuss • contribs) 19:37, 30 December 2016 (UTC)


 * I have just pruned down this solutions page rather mercilessly, and I'd say it does feel a lot less bewildering now. Good call on pointing that out! --Duplode (discuss • contribs) 03:51, 3 January 2017 (UTC)


 * I've just gotten up to this point, and it is kind of confusing to be confronted with the replicate function, which is not seen anywhere earlier in the book. I would propose something like:
 * This follows in the patterns that the book handles up until this point, even though the solution one should probably use in production is the current solution. Trainman261 (discuss • contribs) 13:47, 27 November 2023 (UTC)
 * This follows in the patterns that the book handles up until this point, even though the solution one should probably use in production is the current solution. Trainman261 (discuss • contribs) 13:47, 27 November 2023 (UTC)