[GHC] #15131: Speed up certain Foldable NonEmpty methods
GHC
ghc-devs at haskell.org
Wed May 9 16:59:37 UTC 2018
#15131: Speed up certain Foldable NonEmpty methods
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Core Libraries | Version: 8.2.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4677
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by YitzGale):
Replying to [comment:3 dfeuer]:
> Yours has to hold on to the "and then add one" while calculating the
length of the list.
Are you sure GHC doesn't inline the {{{+1}}}? In any case, this is
slightly better:
{{{#!hs
length (_ :| as) = List.foldl' (\c _ -> c+1) 1 as
}}}
> Same goes for `max` and `min`.
Yes, and also for {{{product}}} and {{{sum}}}, but I did that purposely. I
want the semantics to be the same as for {{{List}}}, which is a bit weird
because it uses {{{foldl}}}. And I don't want to hard-code a copy of the
{{{foldl}}} here. I want it to be fixed automatically if we every get
around to fixing it for List.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15131#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list