mmm-0.1.0.0: Minecraft 1.21.4 implementation in Haskell
Copyright(c) axionbuster 2025
LicenseBSD-3-Clause
Safe HaskellNone
LanguageGHC2021

M.Pack.Internal.Bit

Description

Implements bit-level serialization for boolean flags and bitsets, supporting both variable-length and fixed-length bit patterns.

Synopsis

Documentation

newtype Bitwise (i :: k) a Source #

a wrapper type that enables bit-level packing of boolean product types. the type parameter i specifies the underlying integral type used to store the bits (e.g. Word8, Word16, etc). the type parameter a is the product type containing the boolean fields to be encoded.

Constructors

Bitwise 

Fields

Instances

Instances details
Lift a => Lift (Bitwise i a :: Type) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

lift :: Quote m => Bitwise i a -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Bitwise i a -> Code m (Bitwise i a) #

Functor (Bitwise i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

fmap :: (a -> b) -> Bitwise i a -> Bitwise i b #

(<$) :: a -> Bitwise i b -> Bitwise i a #

NFData a => NFData (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

rnf :: Bitwise i a -> () #

(Typeable i, Typeable k, Data a) => Data (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bitwise i a -> c (Bitwise i a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Bitwise i a) #

toConstr :: Bitwise i a -> Constr #

dataTypeOf :: Bitwise i a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Bitwise i a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bitwise i a)) #

gmapT :: (forall b. Data b => b -> b) -> Bitwise i a -> Bitwise i a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bitwise i a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bitwise i a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Bitwise i a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Bitwise i a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bitwise i a -> m (Bitwise i a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitwise i a -> m (Bitwise i a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitwise i a -> m (Bitwise i a) #

Generic (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Associated Types

type Rep (Bitwise i a) 
Instance details

Defined in M.Pack.Internal.Bit

type Rep (Bitwise i a) = D1 ('MetaData "Bitwise" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "Bitwise" 'PrefixI 'True) (S1 ('MetaSel ('Just "unbitwise") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Bitwise i a -> Rep (Bitwise i a) x #

to :: Rep (Bitwise i a) x -> Bitwise i a #

Read a => Read (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Show a => Show (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

showsPrec :: Int -> Bitwise i a -> ShowS #

show :: Bitwise i a -> String #

showList :: [Bitwise i a] -> ShowS #

Eq a => Eq (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

(==) :: Bitwise i a -> Bitwise i a -> Bool #

(/=) :: Bitwise i a -> Bitwise i a -> Bool #

Ord a => Ord (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

compare :: Bitwise i a -> Bitwise i a -> Ordering #

(<) :: Bitwise i a -> Bitwise i a -> Bool #

(<=) :: Bitwise i a -> Bitwise i a -> Bool #

(>) :: Bitwise i a -> Bitwise i a -> Bool #

(>=) :: Bitwise i a -> Bitwise i a -> Bool #

max :: Bitwise i a -> Bitwise i a -> Bitwise i a #

min :: Bitwise i a -> Bitwise i a -> Bitwise i a #

Hashable a => Hashable (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

hashWithSalt :: Int -> Bitwise i a -> Int

hash :: Bitwise i a -> Int

Bitreppable i a => Pack (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

pack :: Bitwise i a -> Builder Source #

Bitreppable i a => Unpack (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

unpack :: forall (st :: ZeroBitType) r. Parser st r (Bitwise i a) Source #

type Rep (Bitwise i a) Source # 
Instance details

Defined in M.Pack.Internal.Bit

type Rep (Bitwise i a) = D1 ('MetaData "Bitwise" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "Bitwise" 'PrefixI 'True) (S1 ('MetaSel ('Just "unbitwise") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

class Bitreppable i a where Source #

type class for types that can be represented as bit flags. provides methods for converting to and from bit representations.

most users should not need to implement this directly - just derive Generic for your type and declare an instance without implementations:

instance Bitreppable Word8 MyFlags

Minimal complete definition

Nothing

Methods

tobits0 :: a -> Builder Source #

default tobits0 :: (Generic a, GBitRep (Rep a), Integral i, Bits i, Pack i) => a -> Builder Source #

frombits0 :: forall (st :: ZeroBitType) r. Parser st r a Source #

default frombits0 :: forall r (st :: ZeroBitType). (Generic a, GBitRep (Rep a), Integral i, Bits i, Unpack i) => Parser st r a Source #

Instances

Instances details
(Bits i, Integral i, Pack i, Unpack i) => Bitreppable i TeleportFlags Source #

do NOT use 8-bit packing for this type. use a type that is at least 16 bits wide

Instance details

Defined in M.Misc

(Bits i, Integral i, Pack i, Unpack i) => Bitreppable i DisplayedSkinParts Source # 
Instance details

Defined in M.V769.I

newtype Bitset Source #

variable-length bitset

(network representation: little-endian vector of Int64s)

Constructors

Bitset 

Fields

Instances

Instances details
NFData Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

rnf :: Bitset -> () #

Bits Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Data Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bitset -> c Bitset #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bitset #

toConstr :: Bitset -> Constr #

dataTypeOf :: Bitset -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Bitset) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bitset) #

gmapT :: (forall b. Data b => b -> b) -> Bitset -> Bitset #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bitset -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bitset -> r #

gmapQ :: (forall d. Data d => d -> u) -> Bitset -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Bitset -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bitset -> m Bitset #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitset -> m Bitset #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitset -> m Bitset #

Enum Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Generic Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Associated Types

type Rep Bitset 
Instance details

Defined in M.Pack.Internal.Bit

type Rep Bitset = D1 ('MetaData "Bitset" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "Bitset" 'PrefixI 'True) (S1 ('MetaSel ('Just "getbitset") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))

Methods

from :: Bitset -> Rep Bitset x #

to :: Rep Bitset x -> Bitset #

Num Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Read Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Real Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Show Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Eq Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

(==) :: Bitset -> Bitset -> Bool #

(/=) :: Bitset -> Bitset -> Bool #

Ord Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Hashable Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

hashWithSalt :: Int -> Bitset -> Int

hash :: Bitset -> Int

Pack Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

pack :: Bitset -> Builder Source #

Unpack Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

unpack :: forall (st :: ZeroBitType) r. Parser st r Bitset Source #

Lift Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

lift :: Quote m => Bitset -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Bitset -> Code m Bitset #

type Rep Bitset Source # 
Instance details

Defined in M.Pack.Internal.Bit

type Rep Bitset = D1 ('MetaData "Bitset" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "Bitset" 'PrefixI 'True) (S1 ('MetaSel ('Just "getbitset") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))

newtype FixedBitset (i :: k) Source #

a fixed-size bitset with i bits

(implemented identically to Bitset; only difference is that when ser/de occurs, it pads missing bits with zeroes. hence it is also possible to access out-of-bounds bits, and these bits will get silently truncated when ser/de occurs)

Constructors

FixedBitset 

Instances

Instances details
Lift (FixedBitset i :: Type) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

lift :: Quote m => FixedBitset i -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => FixedBitset i -> Code m (FixedBitset i) #

NFData (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

rnf :: FixedBitset i -> () #

Bits (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

(Typeable i, Typeable k) => Data (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FixedBitset i -> c (FixedBitset i) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FixedBitset i) #

toConstr :: FixedBitset i -> Constr #

dataTypeOf :: FixedBitset i -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FixedBitset i)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FixedBitset i)) #

gmapT :: (forall b. Data b => b -> b) -> FixedBitset i -> FixedBitset i #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FixedBitset i -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FixedBitset i -> r #

gmapQ :: (forall d. Data d => d -> u) -> FixedBitset i -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FixedBitset i -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FixedBitset i -> m (FixedBitset i) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FixedBitset i -> m (FixedBitset i) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FixedBitset i -> m (FixedBitset i) #

Enum (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Generic (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Associated Types

type Rep (FixedBitset i) 
Instance details

Defined in M.Pack.Internal.Bit

type Rep (FixedBitset i) = D1 ('MetaData "FixedBitset" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "FixedBitset" 'PrefixI 'True) (S1 ('MetaSel ('Just "getfixedbitset") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))

Methods

from :: FixedBitset i -> Rep (FixedBitset i) x #

to :: Rep (FixedBitset i) x -> FixedBitset i #

Num (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Read (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Real (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Show (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Eq (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Ord (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Hashable (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

KnownNat i => Pack (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

KnownNat i => Unpack (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

Methods

unpack :: forall (st :: ZeroBitType) r. Parser st r (FixedBitset i) Source #

type Rep (FixedBitset i) Source # 
Instance details

Defined in M.Pack.Internal.Bit

type Rep (FixedBitset i) = D1 ('MetaData "FixedBitset" "M.Pack.Internal.Bit" "mmm-0.1.0.0-LGnxNP98iy5DdX3UVbzAAf" 'True) (C1 ('MetaCons "FixedBitset" 'PrefixI 'True) (S1 ('MetaSel ('Just "getfixedbitset") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))