Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 3,631
    • Issues 3,631
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 203
    • Merge Requests 203
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9132

Closed
Open
Opened May 21, 2014 by Blaisorblade@trac-Blaisorblade
  • Report abuse
  • New issue
Report abuse New issue

takeWhile&C. still not fusible

takeWhile is not still fusible, 2 1/2 years after this report:

http://www.haskell.org/pipermail/glasgow-haskell-users/2011-December/021299.html

The discussion suggests making takeWhile a good producer/consumer with foldr/build fusion:

takeWhile' :: (a -> Bool) -> [a] -> [a] takeWhile' p xs = build $ \c n -> foldr (takeWhileF p c n) n xs # INLINE takeWhile' #

takeWhileF p c n x xs = if p x then x c xs else n

Furthermore, the discussion suggests having rewrite rules to go to this version and then rewrite back (if fusion fails).

The report also mentions concatMap (which is a separate known problem). It also mentions drop and dropWhile, but I don't see when they perform allocations, so I think that's an erroneous request.

I experienced the bug on GHC 7.6.3, but it seems still there in base-4.7.0.0, judging from the source: http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-List.html\#takeWhile

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ekmett, hvr
Operating system
Architecture

Related issues

  • Discussion
  • Designs
Assignee
Assign to
7.10.1
Milestone
7.10.1
Assign milestone
Time tracking
None
Due date
None
6
Labels
bug core libraries P::normal runtime perf stream fusion Trac import
Assign labels
  • View project labels
Reference: ghc/ghc#9132