data Currency a c where
BTC :: Currency B.Address B.Satoshi
ZEC :: Currency Z.Address Z.Zatoshi
BTC == BTC = True
ZEC == ZEC = True
show = \case
BTC -> "BTC"
ZEC -> "ZEC"
data Currency' c = forall a. Currency' (Currency a c)
(Currency' BTC) == (Currency' BTC) = True
(Currency' ZEC) == (Currency' ZEC) = True
show (Currency' c) = show c
data Amount
= forall a c.
Amount
{ currency :: !(Currency a c),
(Eq c, Ord c, Monoid c) => IsCurrency c where
B.ssub
cscale (B.Satoshi amt) factor =
let r = toRational amt * factor
in if (r >= 0) then Just (B.Satoshi . round $ r) else Nothing
_Units = B._Satoshi
currency' = Currency' BTC
csub = Z.zsub
cscale (Z.Zatoshi amt) factor =
let r = toRational amt * factor
in if (r >= 0) then Just (Z.Zatoshi . round $ r) else Nothing
_Units = Z._Zatoshi
currency' = Currency' ZEC