Skip to content

Specialize sequence into sequence_ automatically

Currently, every function that has a useful "effect" as well as a potentially large result value, needs to get two implementations: One that accumulates the result in memory and yields it, and one that avoids accumulating it in the first place.

Some examples:

sequence vs. sequence_

mapM vs. mapM_

Parsec's: many vs. skipMany

Now that I am writing parser combinators, I'm finding that I need a "skip" version of each parser I write, if my parser has a large value.

If GHC can detect whether a value is eventually used, it could specialize sequence into sequence_ automatically, when it notices that the list is unused.

Trac metadata
Trac field Value
Version 7.2.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information