I have a little problem in Scala with a typing agent. In Haskell, I can do this:
add :: (Num a) => (a,a) -> (a,a) -> (a,a)
That way, I can add to add any type that is numeric and supports + , etc. I want the same for the Scala class, for example:
case class NumPair[A <: Numeric](x: A, y: A)
But that does not work. But due to Scala Docs, Numeric[T] is the only trait that allows these operations and seems to extend to Int , Float , etc.
Any tips?
types scala functional-programming
Lanbo
source share