Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Conversions between various types.
@since WIP
Synopsis
- data PEndianness (s :: S)
- pmostSignificantFirst :: forall (s :: S). Term s PEndianness
- pmostSignificantLast :: forall (s :: S). Term s PEndianness
- pbyteStringToInteger :: forall (s :: S). Term s PEndianness -> Term s (PByteString :--> PInteger)
- pintegerToByteString :: forall (s :: S). Term s PEndianness -> Term s (PInteger :--> PByteString)
- pintegerToByteStringSized :: forall (s :: S). Term s PEndianness -> Term s (PPositive :--> (PInteger :--> PByteString))
Types
data PEndianness (s :: S) Source #
Type designating whether a conversion should be most-significant-first or most-significant-last. See CIP-121 for more details on this.
@since WIP
Instances
Functions
pmostSignificantFirst :: forall (s :: S). Term s PEndianness Source #
Indicates the conversion should be most-significant-first.
@since WIP
pmostSignificantLast :: forall (s :: S). Term s PEndianness Source #
Indicates the conversion should be most-significant-last.
@since WIP
pbyteStringToInteger :: forall (s :: S). Term s PEndianness -> Term s (PByteString :--> PInteger) Source #
Convert a PByteString
into a PInteger
, as per
CIP-121.
@since WIP
pintegerToByteString :: forall (s :: S). Term s PEndianness -> Term s (PInteger :--> PByteString) Source #
Convert a (non-negative) PInteger
into a PByteString
. This will produce
a result of the minimal size required: if you want to specify a size, use
pintegerToByteStringSized
. For details, see
CIP-121.
Note
This conversion is unsafe, as it will error when given a non-negative integer.
pintegerToByteStringSized :: forall (s :: S). Term s PEndianness -> Term s (PPositive :--> (PInteger :--> PByteString)) Source #
As pintegerToByteString
, but allows specifying a required size. If
a size larger than the minimum is specified, the result will be padded with zero
bytes, positioned according to the endianness argument.
For more details, see CIP-121.
Note
This conversion is unsafe. In addition to the reasons for
punsafeIntegerToByteString
being unsafe, this will also error if the
requested size is too large (currently 8192 is the limit) or too small to fit
the specified PInteger
.