Safe Haskell | None |
---|---|
Language | Haskell2010 |
Core primitive Tezos types.
Synopsis
- data Mutez
- mkMutez :: Word64 -> Maybe Mutez
- unsafeMkMutez :: HasCallStack => Word64 -> Mutez
- toMutez :: Word32 -> Mutez
- addMutez :: Mutez -> Mutez -> Maybe Mutez
- unsafeAddMutez :: HasCallStack => Mutez -> Mutez -> Mutez
- subMutez :: Mutez -> Mutez -> Maybe Mutez
- unsafeSubMutez :: HasCallStack => Mutez -> Mutez -> Mutez
- mulMutez :: Integral a => Mutez -> a -> Maybe Mutez
- divModMutez :: Mutez -> Mutez -> Maybe (Word64, Mutez)
- divModMutezInt :: Integral a => Mutez -> a -> Maybe (Mutez, Mutez)
- newtype Timestamp = Timestamp {}
- timestampToSeconds :: Integral a => Timestamp -> a
- timestampFromSeconds :: Integral a => a -> Timestamp
- timestampFromUTCTime :: UTCTime -> Timestamp
- timestampPlusSeconds :: Timestamp -> Integer -> Timestamp
- formatTimestamp :: Timestamp -> Text
- parseTimestamp :: Text -> Maybe Timestamp
- getCurrentTime :: IO Timestamp
Mutez
Mutez is a wrapper over integer data type. 1 mutez is 1 token (μTz).
Instances
unsafeMkMutez :: HasCallStack => Word64 -> Mutez Source #
toMutez :: Word32 -> Mutez Source #
Safely create Mutez
.
This is recommended way to create Mutez
from a numeric literal;
you can't construct all valid Mutez
values using this function
but for small values it works neat.
Warnings displayed when trying to construct invalid Natural
or Word
literal are hardcoded for these types in GHC implementation, so we can only
exploit these existing rules.
unsafeAddMutez :: HasCallStack => Mutez -> Mutez -> Mutez Source #
Partial addition of Mutez
, should be used only if you're
sure there'll be no overflow.
unsafeSubMutez :: HasCallStack => Mutez -> Mutez -> Mutez Source #
Partial subtraction of Mutez
, should be used only if you're
sure there'll be no underflow.
divModMutez :: Mutez -> Mutez -> Maybe (Word64, Mutez) Source #
Euclidian division of two Mutez
values.
divModMutezInt :: Integral a => Mutez -> a -> Maybe (Mutez, Mutez) Source #
Euclidian division of Mutez
and a number.
Timestamp
Time in the real world. Use the functions below to convert it to/from Unix time in seconds.
Instances
timestampToSeconds :: Integral a => Timestamp -> a Source #
timestampFromSeconds :: Integral a => a -> Timestamp Source #
timestampPlusSeconds :: Timestamp -> Integer -> Timestamp Source #
Add given amount of seconds to a Timestamp
.
formatTimestamp :: Timestamp -> Text Source #
Display timestamp in human-readable way as used by Michelson. Uses UTC timezone, though maybe we should take it as an argument.