containers
containers copied to clipboard
Analogues of `{dropWhile,takeWhile}Antitone` for `IntMap` and `IntSet`
Map
and Set
have these operations, and there is no obvious reason why IntMap
and IntSet
shouldn't have them too.
If translated directly, the type signature would look like this:
dropWhileAntitone :: (Key -> Bool) -> IntMap a -> IntMap a
takeWhileAntitone :: (Key -> Bool) -> IntMap a -> IntMap a
An alternative design could look like this:
data Compare = LessThan | LessThanEqual | GreaterThanEqual | GreaterThan -- | Equal ?
filterCompare :: Compare -> Key -> IntMap a -> IntMap a
The main advantage is that such a function would do the job of both dropWhileAntitone
and takeWhileAntitone
.
For simplicity and consistency with Map
and Set
I think direct translations might be best though.
Consistency is good.
For consistency, spanAntitone
should be added too.
I took a shot at implementing this, should I send a PR?
@meooow25 That would surely be appreciated!