Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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
PByteString
s to use bitwise functionality: this way, it's clear where which
scheme applies.
@since WIP
Instances
Functions
preadBit :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBool)) Source #
Bit access operation, as defined in CIP-122.
@since WIP
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.
@since WIP
Sets bits, as per CIP-122.
@since WIP
pshift :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString)) Source #
Performs a shift, as per CIP-123.
@since WIP
protate :: forall (s :: S). Term s (PBitString :--> (PInteger :--> PBitString)) Source #
Performs a rotation, as per CIP-123.
@since WIP
pcountSetBits :: forall (s :: S). Term s (PBitString :--> PInteger) Source #
Counts the number of set bits, as per CIP-123.
@since WIP
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 WIP
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 WIP