| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Plutarch.BitString
Synopsis
- newtype PBitString (s :: S) = PBitString (Term s PByteString)
- preadBit :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBool))
- pwriteBits :: forall (s :: S). Term s (PBitString :--> (PBuiltinList PInteger :--> (PBool :--> PBitString)))
- pshift :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString))
- protate :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString))
- pcountSetBits :: forall (s :: S). Term s (PBitString :--> PInteger)
- pfindFirstSetBit :: forall (s :: S). Term s (PBitString :--> PMaybe PInteger)
- pfindFirstSetBit' :: forall (s :: S). Term s (PBitString :--> PInteger)
Type
newtype PBitString (s :: S) Source #
A wrapper around PByteString for CIP-122 and CIP-123 bitwise operations.
Note
This type exists because bit and byte indexes work in different
directions. To avoid confusing behaviour, we require an explicit wrapping of
PByteStrings to use bitwise functionality: this way, it's clear where which
scheme applies.
Since: 1.10.0
Constructors
| PBitString (Term s PByteString) |
Instances
Functions
preadBit :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBool)) Source #
Bit access operation, as defined in CIP-122.
Since: 1.10.0
pwriteBits :: forall (s :: S). Term s (PBitString :--> (PBuiltinList PInteger :--> (PBool :--> PBitString))) Source #
Given a list of positions, set the bits at those positions.
This works similarly to the writeBits operation in
CIP-122
with regard to the list of indexes. Effectively, psetBits b ixes is
equivalent to writeBits b . map (, True) $ ixes. All caveats that this
entails from the CIP-122 description apply.
Sets bits, as per CIP-122.
Since: 1.10.0
pshift :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString)) Source #
Performs a shift, as per CIP-123.
Since: 1.10.0
protate :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString)) Source #
Performs a rotation, as per CIP-123.
Since: 1.10.0
pcountSetBits :: forall (s :: S). Term s (PBitString :--> PInteger) Source #
Counts the number of set bits, as per CIP-123.
Since: 1.10.0
pfindFirstSetBit :: forall (s :: S). Term s (PBitString :--> PMaybe PInteger) Source #
As pfindFirstSetBit', but produces PNothing if the argument is empty,
or contains no set bits.
Since: 1.10.0
pfindFirstSetBit' :: forall (s :: S). Term s (PBitString :--> PInteger) Source #
Finds the index of the first set bit, as per CIP-123.
Note
This returns -1 if the argument is either empty, or contains no set bits.
Since: 1.10.0