dollaridoos-0.1.0.0: A newtype for monetary values

Safe HaskellSafe
LanguageHaskell2010

Data.Money

Contents

Description

A data type for monetary values, with associated operations and only sensible instances.

Synopsis

Documentation

newtype Money num Source #

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.

Constructors

Money num 

Instances

Functor Money Source # 

Methods

fmap :: (a -> b) -> Money a -> Money b #

(<$) :: a -> Money b -> Money a #

Foldable Money Source # 

Methods

fold :: Monoid m => Money m -> m #

foldMap :: Monoid m => (a -> m) -> Money a -> m #

foldr :: (a -> b -> b) -> b -> Money a -> b #

foldr' :: (a -> b -> b) -> b -> Money a -> b #

foldl :: (b -> a -> b) -> b -> Money a -> b #

foldl' :: (b -> a -> b) -> b -> Money a -> b #

foldr1 :: (a -> a -> a) -> Money a -> a #

foldl1 :: (a -> a -> a) -> Money a -> a #

toList :: Money a -> [a] #

null :: Money a -> Bool #

length :: Money a -> Int #

elem :: Eq a => a -> Money a -> Bool #

maximum :: Ord a => Money a -> a #

minimum :: Ord a => Money a -> a #

sum :: Num a => Money a -> a #

product :: Num a => Money a -> a #

Traversable Money Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Money a -> f (Money b) #

sequenceA :: Applicative f => Money (f a) -> f (Money a) #

mapM :: Monad m => (a -> m b) -> Money a -> m (Money b) #

sequence :: Monad m => Money (m a) -> m (Money a) #

Eq num => Eq (Money num) Source # 

Methods

(==) :: Money num -> Money num -> Bool #

(/=) :: Money num -> Money num -> Bool #

Ord num => Ord (Money num) Source # 

Methods

compare :: Money num -> Money num -> Ordering #

(<) :: Money num -> Money num -> Bool #

(<=) :: Money num -> Money num -> Bool #

(>) :: Money num -> Money num -> Bool #

(>=) :: Money num -> Money num -> Bool #

max :: Money num -> Money num -> Money num #

min :: Money num -> Money num -> Money num #

Show num => Show (Money num) Source # 

Methods

showsPrec :: Int -> Money num -> ShowS #

show :: Money num -> String #

showList :: [Money num] -> ShowS #

Num a => Semigroup (Money a) Source # 

Methods

(<>) :: Money a -> Money a -> Money a #

sconcat :: NonEmpty (Money a) -> Money a #

stimes :: Integral b => b -> Money a -> Money a #

Num a => Monoid (Money a) Source # 

Methods

mempty :: Money a #

mappend :: Money a -> Money a -> Money a #

mconcat :: [Money a] -> Money a #

Optics

money :: Iso (Money a) (Money b) a b Source #

The raw numeric value inside monetary value

Operators

($+$) :: Num a => Money a -> Money a -> Money a infixl 6 Source #

Add money to money. A synonym for <>.

($-$) :: Num a => Money a -> Money a -> Money a infixl 6 Source #

Subtract money from money

(*$) :: Num a => a -> Money a -> Money a infixr 7 Source #

Multiply a scalar by money

($*) :: Num a => Money a -> a -> Money a infixl 7 Source #

Multiply money by a scalar

($/) :: Fractional a => Money a -> a -> Money a infixl 7 Source #

Divide money by a scalar

($/$) :: Fractional a => Money a -> Money a -> a infixl 7 Source #

Divide money by money

($^) :: (Num a, Integral b) => Money a -> b -> Money a infixr 8 Source #

Raise money to a non-negative integral power

($^^) :: (Fractional a, Integral b) => Money a -> b -> Money a infixr 8 Source #

Raise money to an integral power

($**) :: Floating a => Money a -> a -> Money a infixr 8 Source #

Raise money to a floating-point power