Skip to content

Commit

Permalink
add simple conversion function to '../Types/Coin.hs' from Coin to int…
Browse files Browse the repository at this point in the history
…egrals
  • Loading branch information
KtorZ committed Jan 26, 2021
1 parent fad9634 commit cfabbbd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Types/Coin.hs
Expand Up @@ -14,6 +14,8 @@ module Cardano.Wallet.Primitive.Types.Coin
( -- * Type
Coin (..)
, coinQuantity
, coinToInteger
, coinToNatural

-- * Checks
, isValidCoin
Expand Down Expand Up @@ -100,6 +102,12 @@ instance Buildable Coin where
coinQuantity :: Integral a => Coin -> Quantity n a
coinQuantity (Coin n) = Quantity (fromIntegral n)

coinToInteger :: Coin -> Integer
coinToInteger = fromIntegral . unCoin

coinToNatural :: Coin -> Natural
coinToNatural = fromIntegral . unCoin

{-------------------------------------------------------------------------------
Checks
-------------------------------------------------------------------------------}
Expand Down

0 comments on commit cfabbbd

Please sign in to comment.