-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Labels
Description
There's excessive code duplication in the library due to near-identical implementations of several functions. This duplication has two causes:
- Optimizations:
- In the name of efficiency, some functions have been duplicate to avoid the cost of unused generality. For example, we have separate implementation of
insert
andinsertWith
, even though the former could be implemented in terms of the latter. - To support in-place update in the implementation of e.g.
fromList
, we have in-place versions of some functions e.g.unsafeInsert
.
- In the name of efficiency, some functions have been duplicate to avoid the cost of unused generality. For example, we have separate implementation of
- To provide both a strict and a lazy interface, some operations e.g.
insertWith
, have two implementations which only differs in the use of aseq
or two.
I believe we can get rid of this duplication by implementing some generic functions that the others can be implemented in terms of and inline these hard enough.