Name: numeric-vc
Owner: Underscore
Description: Derives instances of Numeric for value classes
Created: 2016-12-10 22:56:01.0
Updated: 2017-02-27 22:47:10.0
Pushed: 2016-12-11 14:06:04.0
Homepage: null
Size: 14
Language: Scala
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Provides instances of Numeric[T]
for value classes.
I want to give meaningful types to values. I use value classes for this. Sometimes these are numeric, such as:
class Quantity(value: Int) extends AnyVal
For numeric value classes it is sometimes convenient to be able to do:
tity(1) + Quantity(2)
This project enables basic numeric operations on numeric value classes.
Yeah, so I've not published this yet. If you want me to, raise an issue.
Otherwise, copy the source file (numeric.scala) and depend on shapeless (see project/Dependencies.scala).
Then:
ome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
in expressions for evaluation. Or try :help.
a> import io.underscore.numeric.Implicits._
rt io.underscore.numeric.Implicits._
a> import Numeric.Implicits._
rt Numeric.Implicits._
a> case class Count(value: Int) extends AnyVal
ned class Count
a> Count(1) + Count(41)
: Count = Count(42)
See examples.scala for more usage.
Provide core numeric capabilities for value classes. This is not a units library and nor is it a maths library.