cats-collections
cats-collections copied to clipboard
DietMap
I found Diet, which seems quite nice, but I'm particularly interested in a DietMap, which would allow you to store values associated with each range.
dietMap.addRange((1, 10), myCaseClass)
def intersection(range): Seq[V]
I could add dietmap[A,B] to store items of type B associated with ranges of type A. I dont think it is a problem. I just need other things committed first.
@stew I am going to start working on this. The interesting part is merging two nodes. Each Node needs the Range
and and elements in the range. I am thinking on using shapeless to do this since we don't need to fix a type A
. A Node
could potentially look like this:
case class Node[A <: HList, B](range: Range[B], item: A)
in other words, we could do something like this:
Node(Range(10, 20), 5 :: HNil) +
Node(Range(8, 18, "Hello" :: HNil)
will result in:
Node(Range(9, 20), 5 :: "Hello" :: HNil)
What do you think?
Will that work for you @velvia?
I think that it should require a Semigroup on A instead of using an HList
That will work too. I will look into it
@velvia I have done this and open #94 make sure you look at the commit message to see how to use it.
Thanks very much!
On Jun 21, 2017, at 1:25 PM, Nicolas A Perez [email protected] wrote:
@velvia https://github.com/velvia I have done this and open #94 https://github.com/stew/dogs/pull/94 make sure you look at the commit message to see how to use it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stew/dogs/issues/66#issuecomment-310194699, or mute the thread https://github.com/notifications/unsubscribe-auth/ABA32_3wSco1xsp3RuBVg0fHXraYIitBks5sGXwwgaJpZM4Khs2W.
@larsrh I am back to write some code for this project. I would like to resubmit some of my old PRs. between @stew and I wrote most of the structures here and I would like to continue with it.
That's great! I'd be happy to take a look at them.