-
-
Notifications
You must be signed in to change notification settings - Fork 240
Open
Description
In a lot of places in spire, concrete typeclass instances are public. This increases the surface area of the library needlessly. As far as I can see, it also does not have any performance benefit in the typical use case.
So I would propose changing e.g. this (spire.std.int.scala)
trait IntInstances {
implicit final val IntBitString = new IntIsBitString
implicit final val IntAlgebra = new IntAlgebra
import spire.math.NumberTag._
implicit final val IntTag = new BuiltinIntTag[Int](0, Int.MinValue, Int.MaxValue)
}to this
trait IntInstances {
implicit final val IntBitString: BitString[Int] = new IntIsBitString
implicit final val IntAlgebra: EuclideanRing[Int] with NRoot[Int] with Order[Int] with Signed[Int] with IsIntegral[Int] = new IntAlgebra
import spire.math.NumberTag._
implicit final val IntTag : NumberTag[Int] = new BuiltinIntTag[Int](0, Int.MinValue, Int.MaxValue)
}This would allow making everything in spire.std.int.scala except IntInstances private or at least private[spire]. Doing the same everywhere where typeclass instances are defined would result in a large reduction in surface area.
However, this would break some code in case somebody uses e.g. IntOrder in another namespace. So I am not completely sure if this is a good idea. @non @tixxit what do you think?
Metadata
Metadata
Assignees
Labels
No labels