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

2016-12-13 Thread Joachim Breitner
Dear George,

Am Dienstag, den 13.12.2016, 12:24 + schrieb George Colpitts:
> I got confused; when I  I google   "haskell list length" I end up at 
> https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-List.html.
> 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-4.9.0.0/docs/src/Data.Foldable.html#length. 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-4.9.0.0/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
> 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
> (8.0.1.20161117) 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-
> 4.9.0.0/docs/Prelude.html and look at the source code for length you
> end up at https://hackage.haskell.org/package/base-
> 4.9.0.0/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
paper anyways.

Greetings,
Joachim
-- 
Joachim “nomeata” Breitner
  m...@joachim-breitner.de • https://www.joachim-breitner.de/
  XMPP: nome...@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: nome...@debian.org

signature.asc
Description: This is a digitally signed message part
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


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

2016-12-12 Thread Joachim Breitner
Am Montag, den 12.12.2016, 12:44 + schrieb George Colpitts:
> my apologies, sorry for the terrible bug report

No worries! Better a bug report closed as invalid than a real bug
unreported.

Greetings,
Joachim

-- 
-- 
Joachim “nomeata” Breitner
  m...@joachim-breitner.de • https://www.joachim-breitner.de/
  XMPP: nome...@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: nome...@debian.org

signature.asc
Description: This is a digitally signed message part
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


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

2016-12-12 Thread George Colpitts
my apologies, sorry for the terrible bug report

On Sun, Dec 11, 2016 at 11:05 AM GHC  wrote:

> #876: Length is not a good consumer
> -+-
> Reporter:  ariep@…   |Owner:
> Type:  bug   |   Status:  new
> Priority:  lowest|Milestone:  7.6.2
>Component:  libraries/base|  Version:  6.5
>   Resolution:| Keywords:  length
> Operating System:  Linux | Architecture:
>  |  Unknown/Multiple
>  Type of failure:  Runtime   |Test Case:
>   performance bug|  perf/should_run/T876
>   Blocked By:| Blocking:
>  Related Tickets:|  Differential Rev(s):
>Wiki Page:|
> -+-
>
> Comment (by nomeata):
>
>  This code, compiled with `-O, does fuse, and allocates nothing (or
>  constant amounts)
>  {{{#!hs
>
>  module Foo where
>  x :: Int -> Int
>  x n = length [0..(10^n)::Int]
>  }}}
>
>  {{{
>  $ ghci -fobject-code -O Foo
>  GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
>  [1 of 1] Compiling Foo  ( Foo.hs, Foo.o )
>  Ok, modules loaded: Foo.
>  Prelude Foo> :set +s
>  Prelude Foo> x 1
>  11
>  (0.03 secs, 14,976,744 bytes)
>  Prelude Foo> x 7
>  1001
>  (0.02 secs, 0 bytes)
>  Prelude Foo> x 8
>  10001
>  (0.04 secs, 0 bytes)
>  }}}
>
>  (almost) HEAD:
>  {{{
>  GHCi, version 8.1.20161117: http://www.haskell.org/ghc/  :? for help
>  [1 of 1] Compiling Foo  (.hs -> .o)
>  WARNING: file compiler/simplCore/SimplCore.hs, line 663
>Simplifier bailing out after 4 iterations [58, 14, 2, 2]
>  Size = {terms: 96, types: 32, coercions: 0}
>  Ok, modules loaded: Foo (Foo.o).
>  Prelude Foo> :set +s
>  Prelude Foo> x 1
>  11
>  (0.19 secs, 94,792 bytes)
>  Prelude Foo> x 2
>  101
>  (0.01 secs, 94,648 bytes)
>  Prelude Foo> x 7
>  1001
>  (0.01 secs, 98,568 bytes)
>  Prelude Foo> x 8
>  10001
>  (0.05 secs, 98,448 bytes)
>  }}}
>
>  Testing this in with interpreted code is not sufficient, as the optimizer
>  does less in that case. So so far, everything seems as expected to me.
>
> --
> Ticket URL: 
> GHC 
> The Glasgow Haskell Compiler
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs