basement-0.0.16: Foundation scrap box of array & string
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Basement.Types.OffsetSize

Description

 
Synopsis

Documentation

newtype FileSize Source #

File size in bytes

Constructors

FileSize Word64 

Instances

Instances details
Show FileSize Source # 
Instance details

Defined in Basement.Types.OffsetSize

Eq FileSize Source # 
Instance details

Defined in Basement.Types.OffsetSize

Ord FileSize Source # 
Instance details

Defined in Basement.Types.OffsetSize

newtype Offset ty Source #

Offset in a data structure consisting of elements of type ty.

Int is a terrible backing type which is hard to get away from, considering that GHC/Haskell are mostly using this for offset. Trying to bring some sanity by a lightweight wrapping.

Constructors

Offset Int 

Instances

Instances details
From Word (Offset ty) Source # 
Instance details

Defined in Basement.From

Methods

from :: Word -> Offset ty Source #

TryFrom Int (Offset ty) Source # 
Instance details

Defined in Basement.From

Methods

tryFrom :: Int -> Maybe (Offset ty) Source #

Enum (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

succ :: Offset ty -> Offset ty #

pred :: Offset ty -> Offset ty #

toEnum :: Int -> Offset ty #

fromEnum :: Offset ty -> Int #

enumFrom :: Offset ty -> [Offset ty] #

enumFromThen :: Offset ty -> Offset ty -> [Offset ty] #

enumFromTo :: Offset ty -> Offset ty -> [Offset ty] #

enumFromThenTo :: Offset ty -> Offset ty -> Offset ty -> [Offset ty] #

Num (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

(+) :: Offset ty -> Offset ty -> Offset ty #

(-) :: Offset ty -> Offset ty -> Offset ty #

(*) :: Offset ty -> Offset ty -> Offset ty #

negate :: Offset ty -> Offset ty #

abs :: Offset ty -> Offset ty #

signum :: Offset ty -> Offset ty #

fromInteger :: Integer -> Offset ty #

Show (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

showsPrec :: Int -> Offset ty -> ShowS #

show :: Offset ty -> String #

showList :: [Offset ty] -> ShowS #

Integral (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

NormalForm (Offset a) Source # 
Instance details

Defined in Basement.NormalForm

Methods

toNormalForm :: Offset a -> () Source #

Additive (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

azero :: Offset ty Source #

(+) :: Offset ty -> Offset ty -> Offset ty Source #

scale :: IsNatural n => n -> Offset ty -> Offset ty Source #

IsIntegral (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

toInteger :: Offset ty -> Integer Source #

IsNatural (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

toNatural :: Offset ty -> Natural Source #

Subtractive (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Associated Types

type Difference (Offset ty) Source #

Methods

(-) :: Offset ty -> Offset ty -> Difference (Offset ty) Source #

Eq (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

(==) :: Offset ty -> Offset ty -> Bool #

(/=) :: Offset ty -> Offset ty -> Bool #

Ord (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

compare :: Offset ty -> Offset ty -> Ordering #

(<) :: Offset ty -> Offset ty -> Bool #

(<=) :: Offset ty -> Offset ty -> Bool #

(>) :: Offset ty -> Offset ty -> Bool #

(>=) :: Offset ty -> Offset ty -> Bool #

max :: Offset ty -> Offset ty -> Offset ty #

min :: Offset ty -> Offset ty -> Offset ty #

type NatNumMaxBound (Offset x) Source # 
Instance details

Defined in Basement.Types.OffsetSize

type Difference (Offset ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

type Difference (Offset ty) = CountOf ty

type Offset8 = Offset Word8 Source #

Offset in bytes used for memory addressing (e.g. in a vector, string, ..)

offsetCast :: Proxy (a -> b) -> Offset a -> Offset b Source #

offsetSub :: Offset a -> Offset a -> Offset a Source #

subtract 2 CountOf values of the same type.

m need to be greater than n, otherwise negative count error ensue use the safer (-) version if unsure.

sizeCast :: Proxy (a -> b) -> CountOf a -> CountOf b Source #

sizeSub :: CountOf a -> CountOf a -> CountOf a Source #

subtract 2 CountOf values of the same type.

m need to be greater than n, otherwise negative count error ensue use the safer (-) version if unsure.

countOfRoundUp :: Int -> CountOf ty -> CountOf ty Source #

alignment need to be a power of 2

(+.) :: Offset ty -> Int -> Offset ty Source #

(.==#) :: Offset ty -> CountOf ty -> Bool Source #

newtype CountOf ty Source #

CountOf of a data structure.

More specifically, it represents the number of elements of type ty that fit into the data structure.

>>> length (fromList ['a', 'b', 'c', '🌟']) :: CountOf Char
CountOf 4

Same caveats as Offset apply here.

Constructors

CountOf Int 

Instances

Instances details
From Word (CountOf ty) Source # 
Instance details

Defined in Basement.From

Methods

from :: Word -> CountOf ty Source #

TryFrom Int (CountOf ty) Source # 
Instance details

Defined in Basement.From

Methods

tryFrom :: Int -> Maybe (CountOf ty) Source #

Monoid (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

mempty :: CountOf ty #

mappend :: CountOf ty -> CountOf ty -> CountOf ty #

mconcat :: [CountOf ty] -> CountOf ty #

Semigroup (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

(<>) :: CountOf ty -> CountOf ty -> CountOf ty #

sconcat :: NonEmpty (CountOf ty) -> CountOf ty #

stimes :: Integral b => b -> CountOf ty -> CountOf ty #

Enum (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

succ :: CountOf ty -> CountOf ty #

pred :: CountOf ty -> CountOf ty #

toEnum :: Int -> CountOf ty #

fromEnum :: CountOf ty -> Int #

enumFrom :: CountOf ty -> [CountOf ty] #

enumFromThen :: CountOf ty -> CountOf ty -> [CountOf ty] #

enumFromTo :: CountOf ty -> CountOf ty -> [CountOf ty] #

enumFromThenTo :: CountOf ty -> CountOf ty -> CountOf ty -> [CountOf ty] #

Num (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

(+) :: CountOf ty -> CountOf ty -> CountOf ty #

(-) :: CountOf ty -> CountOf ty -> CountOf ty #

(*) :: CountOf ty -> CountOf ty -> CountOf ty #

negate :: CountOf ty -> CountOf ty #

abs :: CountOf ty -> CountOf ty #

signum :: CountOf ty -> CountOf ty #

fromInteger :: Integer -> CountOf ty #

Show (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

showsPrec :: Int -> CountOf ty -> ShowS #

show :: CountOf ty -> String #

showList :: [CountOf ty] -> ShowS #

Integral (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

NormalForm (CountOf a) Source # 
Instance details

Defined in Basement.NormalForm

Methods

toNormalForm :: CountOf a -> () Source #

Additive (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

azero :: CountOf ty Source #

(+) :: CountOf ty -> CountOf ty -> CountOf ty Source #

scale :: IsNatural n => n -> CountOf ty -> CountOf ty Source #

IsIntegral (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

toInteger :: CountOf ty -> Integer Source #

IsNatural (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

toNatural :: CountOf ty -> Natural Source #

Subtractive (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Associated Types

type Difference (CountOf ty) Source #

Methods

(-) :: CountOf ty -> CountOf ty -> Difference (CountOf ty) Source #

Eq (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

(==) :: CountOf ty -> CountOf ty -> Bool #

(/=) :: CountOf ty -> CountOf ty -> Bool #

Ord (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

Methods

compare :: CountOf ty -> CountOf ty -> Ordering #

(<) :: CountOf ty -> CountOf ty -> Bool #

(<=) :: CountOf ty -> CountOf ty -> Bool #

(>) :: CountOf ty -> CountOf ty -> Bool #

(>=) :: CountOf ty -> CountOf ty -> Bool #

max :: CountOf ty -> CountOf ty -> CountOf ty #

min :: CountOf ty -> CountOf ty -> CountOf ty #

From (CountOf ty) Int Source # 
Instance details

Defined in Basement.From

Methods

from :: CountOf ty -> Int Source #

From (CountOf ty) Word Source # 
Instance details

Defined in Basement.From

Methods

from :: CountOf ty -> Word Source #

type NatNumMaxBound (CountOf x) Source # 
Instance details

Defined in Basement.Types.OffsetSize

type Difference (CountOf ty) Source # 
Instance details

Defined in Basement.Types.OffsetSize

type Difference (CountOf ty) = Maybe (CountOf ty)

natValCountOf :: forall n ty proxy. (KnownNat n, NatWithinBound (CountOf ty) n) => proxy n -> CountOf ty Source #

natValOffset :: forall n ty proxy. (KnownNat n, NatWithinBound (Offset ty) n) => proxy n -> Offset ty Source #