Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Improved representation for Set and Map

Open
#1,073 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
haskell
Domain
performance

Research direction

Review the current Set and Map representations and the referenced containers PR #1069 discussion first; the issue does not identify implementation files or tests. Determine which proposed representation is selected, then validate the invariants and the claimed memory and performance effects before considering the work complete.

Written by the indexing model from the issue text.

Description

discussion/rfc Map performance Set

Consider changing the representation to avoid Tips.

Suggested by wrengr in https://github.com/haskell/containers/pull/1069#issuecomment-2504945201


I'm thinking

data Set a
  = Bin !Int !a !(Set a) !(Set a)
  | Two !a !a
  | One !a
  | Nil -- Invariant: Never a child of Bin

This hopefully improves performance but certainly improves memory usage. Compared to today, for n elements we can avoid storing ~n Tips and ~n/2-2n/3 Ints.

Alternately, as midway between current and the above,

data Set a
  = Bin !Int !a !(Set a) !(Set a)
  | One !a
  | Tip
-- Invariant: Bin _ x Tip Tip is always replaced with One x

This puts the match-on-singleton idea of #1069 into the type. Avoids storing ~2n/3-n Tips and ~n/3-n/2 Ints.

Dominant language
Haskell
Stars
355
Forks
194
Avg merge
2d 12h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/containers

All issues in haskell/containers

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.