vst / parala

Experimental Operational Monetary Semantics

GitHub

parala: Operational Monetary Semantics

Note that this is an experimental project. Use at your own risk and sadness.

This repository is using git-flow. Therefore you might want to check other branches, too.

parala provides a small Scala library to operate on monetary values with proper[!] operational and conversion semantics. Briefly:

// Define monetary values and carry on basic operations:
val usd1 = Money(Currency.USD, 1, LocalDate.now())
val usd2 = usd1 + usd1
val eur1 = Money(Currency.EUR, 1, LocalDate.now())
val eur2 = eur1 + eur1
val usd10 = usd1 * 10

// Define a silly converter:
implicit val converter = new Converter () {
  def getRate[CCY1 <: Currency, CCY2 <: Currency](from: CCY1, to: CCY2, asof: LocalDate): Option[Rate[CCY1, CCY2]] = {
    Some(Rate(from, to, Math.random(), asof))
  }
}

// Basic operations on monetary values of mixed currencies:
val guess = usd1 + eur1

License

Copyright 2015-2016 Vehbi Sinan Tunalioglu <vst@vsthost.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.