Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for working with
Value
.
Synopsis
- newtype CurrencySymbol = CurrencySymbol { }
- currencySymbol :: ByteString -> CurrencySymbol
- mpsSymbol :: MintingPolicyHash -> CurrencySymbol
- currencyMPSHash :: CurrencySymbol -> MintingPolicyHash
- adaSymbol :: CurrencySymbol
- newtype TokenName = TokenName { }
- tokenName :: ByteString -> TokenName
- toString :: TokenName -> String
- adaToken :: TokenName
-
newtype
AssetClass
=
AssetClass
{
- unAssetClass :: ( CurrencySymbol , TokenName )
- assetClass :: CurrencySymbol -> TokenName -> AssetClass
- assetClassValue :: AssetClass -> Integer -> Value
- assetClassValueOf :: Value -> AssetClass -> Integer
- newtype Value = Value { }
- singleton :: CurrencySymbol -> TokenName -> Integer -> Value
- valueOf :: Value -> CurrencySymbol -> TokenName -> Integer
- scale :: Module s v => s -> v -> v
- symbols :: Value -> [ CurrencySymbol ]
- geq :: Value -> Value -> Bool
- gt :: Value -> Value -> Bool
- leq :: Value -> Value -> Bool
- lt :: Value -> Value -> Bool
- isZero :: Value -> Bool
- split :: Value -> ( Value , Value )
- unionWith :: ( Integer -> Integer -> Integer ) -> Value -> Value -> Value
- flattenValue :: Value -> [( CurrencySymbol , TokenName , Integer )]
Currency symbols
newtype CurrencySymbol Source #
Instances
currencySymbol :: ByteString -> CurrencySymbol Source #
Creates
CurrencySymbol
from raw
ByteString
.
mpsSymbol :: MintingPolicyHash -> CurrencySymbol Source #
The currency symbol of a monetay policy hash
currencyMPSHash :: CurrencySymbol -> MintingPolicyHash Source #
The minting policy hash of a currency symbol
adaSymbol :: CurrencySymbol Source #
The
CurrencySymbol
of the
Ada
currency.
Token names
ByteString of a name of a token, shown as UTF-8 string when possible
Instances
Asset classes
newtype AssetClass Source #
An asset class, identified by currency symbol and token name.
AssetClass | |
|
Instances
assetClass :: CurrencySymbol -> TokenName -> AssetClass Source #
assetClassValue :: AssetClass -> Integer -> Value Source #
A
Value
containing the given amount of the asset class.
assetClassValueOf :: Value -> AssetClass -> Integer Source #
Get the quantity of the given
AssetClass
class in the
Value
.
Value
A cryptocurrency value. This is a map from
CurrencySymbol
s to a
quantity of that currency.
Operations on currencies are usually implemented
pointwise
. That is,
we apply the operation to the quantities for each currency in turn. So
when we add two
Value
s the resulting
Value
has, for each currency,
the sum of the quantities of
that particular
currency in the argument
Value
. The effect of this is that the currencies in the
Value
are "independent",
and are operated on separately.
Whenever we need to get the quantity of a currency in a
Value
where there
is no explicit quantity of that currency in the
Value
, then the quantity is
taken to be zero.
See note [Currencies] for more details.
Instances
singleton :: CurrencySymbol -> TokenName -> Integer -> Value Source #
Make a
Value
containing only the given quantity of the given currency.
valueOf :: Value -> CurrencySymbol -> TokenName -> Integer Source #
Get the quantity of the given currency in the
Value
.
symbols :: Value -> [ CurrencySymbol ] Source #
The list of
CurrencySymbol
s of a
Value
.
Partial order operations
gt :: Value -> Value -> Bool Source #
Check whether one
Value
is strictly greater than another.
This is *not* a pointwise operation.
gt l r
means
geq l r && not (eq l r)
.
lt :: Value -> Value -> Bool Source #
Check whether one
Value
is strictly less than another.
This is *not* a pointwise operation.
lt l r
means
leq l r && not (eq l r)
.
Etc.
split :: Value -> ( Value , Value ) Source #
Split a value into its positive and negative parts. The first element of the tuple contains the negative parts of the value, the second element contains the positive parts.
negate (fst (split a)) plus
(snd (split a)) == a
flattenValue :: Value -> [( CurrencySymbol , TokenName , Integer )] Source #
Convert a value to a simple list, keeping only the non-zero amounts.