Trying to make a scala.collection.immutable.NumericRange[UInt]
Looks like it needs a scala.math.Integral[UInt]
.
But there does not seem to be a spire.math.Integral[UInt]
.
I am assuming thats because UInt
violates the laws around Integral
in some way.
I am mostly interested in NumericRange[UInt].contains(x: UInt)
Is it folly for me to attempt to construct a scala.math.Integral[UInt]
on my own?
Or should I find some other way to get contains
?
Is there a trait that should exist that should be inherited by Set[T]
and Range
and NumericRange[T]
that declares contains[T]
What should that trait be called?
Should I do this as a type class?
What should I call this type class?
If you just need
contains(x: UInt)
, you should usespire.math.Interval[UInt]
See: https://typelevel.org/spire/api/spire/math/Interval.html
If you need other bits of the
NumericRange[UInt]
then see other answers that arrive in the future.