Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
A data type for monetary values, with associated operations and only sensible instances.
- newtype Money num = Money num
- money :: Iso (Money a) (Money b) a b
- ($+$) :: Num a => Money a -> Money a -> Money a
- ($-$) :: Num a => Money a -> Money a -> Money a
- (*$) :: Num a => a -> Money a -> Money a
- ($*) :: Num a => Money a -> a -> Money a
- ($/) :: Fractional a => Money a -> a -> Money a
- ($/$) :: Fractional a => Money a -> Money a -> a
- ($^) :: (Num a, Integral b) => Money a -> b -> Money a
- ($^^) :: (Fractional a, Integral b) => Money a -> b -> Money a
- ($**) :: Floating a => Money a -> a -> Money a
Documentation
A newtype for monetary values represented as type num
.
The Semigroup
instance allows amounts of money to be added together.
Any Num
instances present are hidden, as operations like multiplying
money by money don't make any sense.
Money num |
Optics
Operators
($+$) :: Num a => Money a -> Money a -> Money a infixl 6 Source #
Add money to money. A synonym for <>
.
($^) :: (Num a, Integral b) => Money a -> b -> Money a infixr 8 Source #
Raise money to a non-negative integral power