[GHC] #876: Length is not a good consumer
mail at joachim-breitner.de
Tue Dec 13 15:11:17 UTC 2016
Am Dienstag, den 13.12.2016, 12:24 +0000 schrieb George Colpitts:
> I got confused; when I I google "haskell list length" I end up at
> When I look at the source code for length by clicking on "Source" It
> takes me to the start of the file https://hackage.haskell.org/package
> /base-22.214.171.124/docs/src/Data.Foldable.html#length. instead of the
> definition of length in https://hackage.haskell.org/package/base-4.9.
> To me, this seems like a bug in haddock. In Data.List.html when I
> click on the source code for init I go to https://hackage.haskell.org
> /package/base-126.96.36.199/docs/src/GHC.List.html#init. This is the file
> I should go to for the source code for length also. Perhaps the
> problem is that the type of length in Data.List is Foldable t => t a
> -> Int while init is [a] -> [a] ? Should I file a haddock bug for the
not, this is all right and intentional. Data.List re-exports
Data.Foldable.length so that you do not get import conflicts when
importing both. This was a design decision back then when the FTP
(Foldable/Traversable) proposal was enacted.
> There seems to be two minor related problems with the Users Guide
> (188.8.131.5261117) in section 10.32.6,List fusion. First, it should
> mention length as a good consumer. Secondly, it says: "If you want to
> write your own good consumers or producers, look at the Prelude
> definitions of the above functions to see how to do so." However if
> you go to https://hackage.haskell.org/package/base-
> 184.108.40.206/docs/Prelude.html and look at the source code for length you
> end up at https://hackage.haskell.org/package/base-
> 220.127.116.11/docs/src/Data.Foldable.html#length which is not a good
> consumer. I think the User's Guide should be changed to replace
> "Prelude" with "Data.List" in the quoted sentence. I'll file a doc
> bug on the User's Guide for these two issues.
Yes, that would be helpful. The text has not been added since FTP.
Maybe even better, the user’s guide could simply contain a section that
explains how to make good consumers and producer, including the hoops
that one has to jump through when one wants to use the library’s
version of a function when no fusion happens. Maybe together with David
Feuer, who most recently battled with that.
Maybe I can write that, I just had to write about list fusion for a
Joachim “nomeata” Breitner
mail at joachim-breitner.de • https://www.joachim-breitner.de/
XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: This is a digitally signed message part
More information about the ghc-devs