cats
cats copied to clipboard
Instances for Currency
Hi,
I often work with the java Currency
type, but wasn't able to find the basic instances for that, e.g. Show
and Eq
.
I also looked in the mouse
project.
Would them be a good fit somewhere?
Every time I ask "why don't we support ____" from java.*
, the answer is lacking support in Scala.js and/or Scala Native. Unless that's also the problem here, I see no reason not to support them.
Lack of support on JS/Native doesn't need to stop us. We can add the instances only for JVM, or add them for all platforms but test only on JVM.
Check out the Typelevel Squants project, one of my favorite projects. Squants includes type-safe value objects representing daily things, including currency.
import squants.market._
val usd3 = USD(30) usd3.toFormattedString should be ("$30.00");
val usd = USD(30) val usd2 = USD(50) val total = usd + usd2 total should be(USD(80))
On Mon, Feb 19, 2024 at 12:21 PM Arman Bilge @.***> wrote:
Lack of support on JS/Native doesn't need to stop us. We can add the instances only for JVM, or add them for all platforms but test only on JVM.
— Reply to this email directly, view it on GitHub https://github.com/typelevel/cats/issues/4562#issuecomment-1953049943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADEJBLDQBCGKMZ5J3SN4E3YUOQ3HAVCNFSM6AAAAABDP52CFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGA2DSOJUGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Lack of support on JS/Native doesn't need to stop us. We can add the instances only for JVM, or add them for all platforms but test only on JVM.
Some times we found libraries that filled the gap, like scala-java-time in cats-time.
Actually there was a proposal to move cats-time
instances into Cats core.
- https://github.com/typelevel/cats/pull/3910#issuecomment-979975262
@dhinojosa thanks for pointing me to squants, I'll play with it and see if it suits in our project.
Every time I ask "why don't we support ____" from
java.*
, the answer is lacking support in Scala.js and/or Scala Native. Unless that's also the problem here, I see no reason not to support them.