cats-collections icon indicating copy to clipboard operation
cats-collections copied to clipboard

DietMap

Open velvia opened this issue 8 years ago • 8 comments

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]

velvia avatar Oct 26 '16 21:10 velvia

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.

anicolaspp avatar Oct 27 '16 02:10 anicolaspp

@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?

anicolaspp avatar Feb 13 '17 22:02 anicolaspp

I think that it should require a Semigroup on A instead of using an HList

stew avatar Mar 13 '17 19:03 stew

That will work too. I will look into it

anicolaspp avatar Mar 13 '17 19:03 anicolaspp

@velvia I have done this and open #94 make sure you look at the commit message to see how to use it.

anicolaspp avatar Jun 21 '17 20:06 anicolaspp

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.

velvia avatar Jun 22 '17 06:06 velvia

@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.

anicolaspp avatar Oct 08 '18 19:10 anicolaspp

That's great! I'd be happy to take a look at them.

larsrh avatar Oct 08 '18 19:10 larsrh