Skip to content

Add containers group for redundant toList hints (fixes #1570)#1689

Open
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:fix/containers-tolist
Open

Add containers group for redundant toList hints (fixes #1570)#1689
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:fix/containers-tolist

Conversation

@mgajda
Copy link
Copy Markdown

@mgajda mgajda commented Apr 19, 2026

Summary

Fixes #1570. Adds a new hint group containers with rewrites that skip
redundant toList calls from Data.IntMap, Data.IntSet, Data.Map
and Data.Set:

  • null (Data.Map.toList x)Data.Map.null x
  • length (Data.IntMap.toList x)Data.IntMap.size x
  • foldMap f (Data.Map.toList x)Data.Map.foldMapWithKey (curry f) x
  • elem y (Data.Set.toList x)Data.Set.member y x
  • … and equivalents for the three other containers.

All rewrite targets are fully qualified, so the group is safe to enable
by default — it only fires when the qualified containers API is already
in use.

…1570)

New hint group `containers` with rewrites that bypass the intermediate
list produced by `Data.IntMap.toList`, `Data.IntSet.toList`,
`Data.Map.toList` and `Data.Set.toList` in favour of the container's
own fold and predicate primitives.

Adds a matching `package: containers` declaration so the group's
`imports:` can reference it. All rewrite targets are fully qualified
(`Data.Map.null`, `Data.IntSet.member`, etc.), so the group is safe to
enable by default: it only fires when the qualified containers API is
already in use.
@mgajda mgajda force-pushed the fix/containers-tolist branch from 4e09bde to f33b6fb Compare April 19, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

avoid redundant toList-calls in containers package

1 participant