ekmett / tables

Deprecated because of
https://github.com/ekmett/tables/issues/15
Other
78 stars 13 forks source link

Check collisions function #33

Open jkarni opened 9 years ago

jkarni commented 9 years ago

Using the examples/Foo.hs:

> test
fromList [Foo {fooId = 1, fooBar = "One", fooBaz = 1.0},Foo {fooId = 2, fooBar = "Two", fooBaz = 2.0},Foo {fooId = 3, fooBar = "Three", fooBaz = 3.0},Foo {fooId = 4, fooBar = "Four", fooBaz = 4.0},Foo {fooId = 5, fooBar = "Five", fooBaz = 5.0}]

> count test
5

> insert (Foo 2 "Two" 1.0) test
fromList [Foo {fooId = 2, fooBar = "Two", fooBaz = 1.0},Foo {fooId = 3, fooBar = "Three", fooBaz = 3.0},Foo {fooId = 4, fooBar = "Four", fooBaz = 4.0},Foo {fooId = 5, fooBar = "Five", fooBaz = 5.0}]

> count $ insert (Foo 2 "Two" 1.0) test
4

I would expect inserts that are conditional on there being no collisions are a more common use-case than removing all collisions (and that perhaps insert is a slightly confusing name for something that can result in fewer entries). Could such a conditional-insert functionality be provided?

ekmett commented 9 years ago

I have no particular objection to accepting such a function into the library.