| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Value.Raw
Description
Immutable advanced value snapshots retaining native stored-state details. Ordinary Cometa.Value is a normalized quantity bundle; this module keeps explicit zero assets, repeated names and empty policy groups. These snapshots are not transaction outputs and do not establish ledger validity.
import qualified Cometa.Value.Raw as Raw emptySnapshot = Raw.mkSnapshot 0 []
Documentation
Signed coin plus raw native-asset associations. Equality compares every stored entry, including zero quantities, repeated names and empty groups. Values are Haskell-owned immutable snapshots; retaining one preserves it when another snapshot is assembled or converted. No cloning allocation is needed.
Instances
mkSnapshot :: Integer -> [(PolicyId, [(AssetName, Integer)])] -> Either Error Snapshot Source #
Validate signed 64-bit coin and asset quantities, returning
InvalidValueQuantity on overflow. Policies sort by hash bytes; repeated
policy keys use the last supplied group. Names sort stably by byte length,
then bytes, retaining repeated names in their supplied tie order. Explicit
zeros and empty groups remain. The signed coin is raw accounting state;
negative coin is not a valid transaction-output amount.
coin :: Snapshot -> Integer Source #
Signed coin quantity in lovelace, within the native signed 64-bit range.
assets :: Snapshot -> [(PolicyId, [(AssetName, Integer)])] Source #
Stored policy/name associations in the order documented by mkSnapshot.
The returned lists retain zero quantities, repeated names and empty groups.
fromValue :: Value -> Either Error Snapshot Source #
Snapshot a normalized bundle, checking native signed 64-bit bounds. Input normalization has already removed zero entries and combined repeated assets; this operation cannot recover that discarded representation information.
toValue :: Snapshot -> Value Source #
Explicitly normalize a raw snapshot into an ordinary bundle. This is lossy:
repeated names are added, zeros and empty groups disappear. The summed result
may exceed native bounds, which ordinary value encoders validate separately.
For any successfully snapshotted bundle, fmap toValue (fromValue value) ==
Right value. The reverse composition need not preserve a raw snapshot.