[GHC] #876: Length is not a good consumer

Joachim Breitner mail at joachim-breitner.de
Tue Dec 13 15:11:17 UTC 2016

Dear George,

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 
> https://hackage.haskell.org/package/base-
> 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- instead of the
> definition of length in https://hackage.haskell.org/package/base-4.9.
> 0.0/docs/src/GHC.List.html#length. 
> 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-  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
> preceding?

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
> ( 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-
> and look at the source code for length you
> end up at https://hackage.haskell.org/package/base-
> 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
paper anyways.

Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttps://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...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20161213/4ab3e213/attachment.sig>

More information about the ghc-devs mailing list