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

Add traverseMonotonic, etc.

Open
#816 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell
Domain
data

Research direction

Start by locating the existing mapMonotonic implementations and related APIs in Data.Set and Data.Map. Add the proposed Set and Map traversal functions as analogous operations, then check the surrounding tests and documentation for expected exports and invariant-preserving behavior.

Written by the indexing model from the issue text.

Description

feature-request Map Set
import Data.Set.Internal

traverseMonotonic :: Applicative t => (a -> t b) -> Set a -> t (Set b)
traverseMonotonic _ Tip = pure Tip
traverseMonotonic f (Bin sz x l r) = flip (Bin sz) <$> traverseMonotonic f l <*> f x <*> traverseMonotonic f r
import Data.Map.Internal

traverseKeysMonotonic :: Applicative t => (k1 -> t k2) -> Map k1 a -> t (Map k2 a)
traverseKeysMonotonic _ Tip = pure Tip
traverseKeysMonotonic f (Bin sz k x l r) = (\l' k' -> Bin sz k' x l') <$> traverseKeysMonotonic f l <*> f k <*> traverseKeysMonotonic f r

bitraverseMonotonic :: Applicative t => (k1 -> t k2) -> (v1 -> t v2) -> Map k1 v1 -> t (Map k2 v2)
bitraverseMonotonic _ _ Tip = pure Tip
bitraverseMonotonic f g (Bin sz k x l r) = (\l' k' x' -> Bin sz k' x' l') <$> bitraverseMonotonic f g l <*> f k <*> g x <*> bitraverseMonotonic f g r

I think we should add these to Data.Set and Data.Map, respectively, as analogues of mapMonotonic, etc. Note that these are unsafe just like they are, and require the exact same care to avoid breaking invariants.

Dominant language
Haskell
Stars
356
Forks
195
Avg merge
3d 42m
Merged PRs (30d)
5

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.