plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.BitString

Synopsis

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 WIP

Constructors

PBitString (Term s PByteString) 

Instances

Instances details
PEq PBitString Source #

@since WIP

Instance details

Defined in Plutarch.BitString

Methods

(#==) :: forall (s :: S). Term s PBitString -> Term s PBitString -> Term s PBool Source #

POrd PBitString Source #

@since WIP

Instance details

Defined in Plutarch.BitString

Methods

(#<=) :: forall (s :: S). Term s PBitString -> Term s PBitString -> Term s PBool Source #

(#<) :: forall (s :: S). Term s PBitString -> Term s PBitString -> Term s PBool Source #

pmax :: forall (s :: S). Term s PBitString -> Term s PBitString -> Term s PBitString Source #

pmin :: forall (s :: S). Term s PBitString -> Term s PBitString -> Term s PBitString Source #

DerivePlutusType PBitString Source #

@since WIP

Instance details

Defined in Plutarch.BitString

Associated Types

type DPTStrat PBitString Source #

PlutusType PBitString Source # 
Instance details

Defined in Plutarch.BitString

Methods

pcon' :: forall (s :: S). PBitString s -> Term s (PInner PBitString) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PBitString) -> (PBitString s -> Term s b) -> Term s b Source #

Generic (PBitString s) Source # 
Instance details

Defined in Plutarch.BitString

Associated Types

type Rep (PBitString s) :: Type -> Type Source #

Methods

from :: PBitString s -> Rep (PBitString s) x Source #

to :: Rep (PBitString s) x -> PBitString s Source #

type DPTStrat PBitString Source # 
Instance details

Defined in Plutarch.BitString

type PContravariant' PBitString Source # 
Instance details

Defined in Plutarch.BitString

type PCovariant' PBitString Source # 
Instance details

Defined in Plutarch.BitString

type PInner PBitString Source #

@since WIP

Instance details

Defined in Plutarch.BitString

type PVariant' PBitString Source # 
Instance details

Defined in Plutarch.BitString

type Rep (PBitString s) Source #

@since WIP

Instance details

Defined in Plutarch.BitString

type Rep (PBitString s) = D1 ('MetaData "PBitString" "Plutarch.BitString" "plutarch-1.9.0-FtN0mhIoM9oEvz7Q98pjWP" 'True) (C1 ('MetaCons "PBitString" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s PByteString))))

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