Functional Weave
Code in Python

money.add@1.0.0

impl/python.py

394 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .money_amount import Money, assert_same_currency, money  ← from money.amount ^1.0.0 · built alongside by fune


def add_money(a: Money, b: Money) -> Money:
    assert_same_currency(a, b)
    return money(a.minor + b.minor, a.currency)


def subtract_money(a: Money, b: Money) -> Money:
    assert_same_currency(a, b)
    return money(a.minor - b.minor, a.currency)


def negate_money(a: Money) -> Money:
    return money(-a.minor, a.currency)