Skip to content

Scala functional library to deal amounts of money. The goal is to provide basic mathematical reasoning to work in money currency and exchange rate.

License

Notifications You must be signed in to change notification settings

FabioPinheiro/cats-money

Repository files navigation

Cats-Money

Scala functional library to deal amounts of money. The goal is to provide basic mathematical reasoning to work in money currency and exchange rate.

See the Documentation website https://fabiopinheiro.github.io/cats-money/

Build Status Codacy Badge Codacy Badge

Power by cats & shapeless:

Cats Friendly Badge & &

Getting Started with Gitpod

Open in Gitpod

To use the online IDE dondload and install the Visual Studio plugins from the marketplace:

To compile and run you can install scala and sbt: sdk install scala & sdk install sbt

Getting Started locally

You will need to have Git, Java 8, and SBT installed.

We try to have a similar structure to the cats library. Have a look of the Cats Infographic from tpolecat and to the Underscore's Scala Book.

You can also start a Scala console from in SBT (scala> prompt) to play with small snippets of code:

import cats._, implicits._
import shapeless._, record._, union._, syntax.singleton._
import app.fmgp.money.instances.all._

import app.fmgp.money._
import app.fmgp.money.MoneyY._
import app.fmgp.money.CurrencyY._

Have a look on the to Demos for more examples (on the test folder):

  • sbt "test:runMain app.fmgp.money.Demo"
  • sbt "test:runMain app.fmgp.money.Main"

Adopters

This is still only a draft and experimental library. But I plane to use this on the near future. If anyone else is also looking for a functional approach to work with monetary value, send me a messagem. (I would appreciate example use cases to better reflect over the library.)

Maintainers

The current maintainers (people who can merge pull requests) are:

TODO LIST

  • implement:
  • rename classes and draw a UML
    • rename MoneyY and CurrencyY files
    • rename MoneyY to Money.
    • move all the other Money type to other place (like 'experimental' package)
  • currency
    • add all currencies from ISO-4217
    • create subset type of currencies
      • [-] try shapeless Union type
        type U = Union.`'a -> EUR, 'b -> USD`.T
        val u1 = Coproduct[U]('a ->> EUR)
        println("u1", u1)
      • try Dotty Union Types =)
    • implement the rates conversion on a subset of currencies
      • [-] try shapeless polymorphic function
        object polymorphicF extends Poly1 {
          implicit def caseEUR = at[EUR.type](i => "sEUR")
          implicit def caseSUSD = at[USD.type](s => "sUSD")
        }
        type CU = EUR.type :+: USD.type :+: CNil
        val cu = Coproduct[CU](USD)
        println("cu", cu, cu map polymorphicF)
  • tests:
  • demo:
    • [WIP] (+- Done) Demo Main
  • to try:
    • Epimorphism, Monomorphism and Isomorphism
    • Rings +-

Copyright and License

cats-money is licensed under the MIT license, available at http://opensource.org/licenses/mit-license.php and also in the LICENSE file.

Copyright the Fabio Pinheiro, 2020.

About

Scala functional library to deal amounts of money. The goal is to provide basic mathematical reasoning to work in money currency and exchange rate.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •