Opened 15 months ago

Last modified 15 months ago

#13086 new bug

(\\) in Data.List uses foldl instead of foldl'

Reported by: vaibhavsagar Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 8.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The list difference operator (\\) is currently defined in terms of foldl: Should it be using foldl' instead?

Change History (1)

comment:1 Changed 15 months ago by nomeata

It probably doesn’t make a difference. The accumulator here is of type [a] and the function passed to foldl is delete, which is lazy. So forcing the first element of the list will make delete only progress until the next retained element of the list, but the rest will still be a thunk.

If you show some benchmarks indicating genuine improvement, we can certainly change this.

Note: See TracTickets for help on using tickets.