These are chat archives for non/algebra

26th
Apr 2016
Merlijn Boogerd
@mboogerd
Apr 26 2016 20:20
A quick question, what is the recommended way of having Spire typeclasses map onto those of Algebra? I would like to use Spire's ULong/Natural as a BoundedJoinSemilattice and I hope to to avoid having to write implicits for each typeclass I need to map.
Adelbert Chang
@adelbertc
Apr 26 2016 20:44
@mboogerd i think for now you need to write your own shims
but the eventual goal is to move spire onto algebra?
Merlijn Boogerd
@mboogerd
Apr 26 2016 20:52
@adelbertc Not certain if I understand your question, I simply need a small number of Spire's implementations and use them in a context that already relies on algebra's typeclasses
I had figured that such a shim would have been a common request, but it's certainly not too much trouble doing it myself :)
Adelbert Chang
@adelbertc
Apr 26 2016 20:55
ah yeah i havent heard of any shim yet myself
P. Oscar Boykin
@johnynek
Apr 26 2016 20:55
@mboogerd you need to make your own instances of BoundedJoinSemilattice in this case. In this case I think you want: https://github.com/non/algebra/blob/master/lattice/src/main/scala/algebra/lattice/DistributiveLattice.scala#L25
so, you just need to make an algebra.Order and you are good to go
you want bounded
Merlijn Boogerd
@mboogerd
Apr 26 2016 20:57
ah yes, I got confused :D
P. Oscar Boykin
@johnynek
Apr 26 2016 20:58
but that may still be more constrained than you want. :/
the plan is for spire (and algebird and others) to adopt these typeclasses
for now, you may need to write some instances yourself
Merlijn Boogerd
@mboogerd
Apr 26 2016 20:59
I need (Partial)Order and (Bounded)JoinSemilattice, I figured it was just a matter of providing implicit conversions for those exact instances
ah, so that is what Adelbert meant, not that this was my goal, but that moving Spire onto algebra is a goal of the Spire community? that would make more sense
P. Oscar Boykin
@johnynek
Apr 26 2016 21:00
yes, that’s right
so we can write generic algorithms and share across cats, spire, algebird, etc...
Merlijn Boogerd
@mboogerd
Apr 26 2016 21:01
sounds awesome :)
alright, thanks @adelbertc and @johnynek for thinking along with me!
P. Oscar Boykin
@johnynek
Apr 26 2016 21:02
:)