basement-0.0.15: Foundation scrap box of array & string
License BSD-style
Maintainer Vincent Hanquez <vincent@snarc.org>
Stability experimental
Portability portable
Safe Haskell None
Language Haskell2010

Basement.Types.OffsetSize

Description

Synopsis

Documentation

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
TryFrom Int ( Offset ty) Source #
Instance details

Defined in Basement.From

From Word ( Offset ty) Source #
Instance details

Defined in Basement.From

Enum ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Eq ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Num ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Ord ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Show ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Integral ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

IsNatural ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

IsIntegral ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Subtractive ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Associated Types

type Difference ( Offset ty) Source #

Additive ( Offset ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

NormalForm ( Offset a) Source #
Instance details

Defined in Basement.NormalForm

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 Offset8 = Offset Word8 Source #

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

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.

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

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
TryFrom Int ( CountOf ty) Source #
Instance details

Defined in Basement.From

From Word ( CountOf ty) Source #
Instance details

Defined in Basement.From

Enum ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Eq ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Num ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Ord ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Show ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Semigroup ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Monoid ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Integral ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

IsNatural ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

IsIntegral ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Subtractive ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

Associated Types

type Difference ( CountOf ty) Source #

Additive ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

NormalForm ( CountOf a) Source #
Instance details

Defined in Basement.NormalForm

From ( CountOf ty) Word Source #
Instance details

Defined in Basement.From

From ( CountOf ty) Int Source #
Instance details

Defined in Basement.From

type NatNumMaxBound ( CountOf x) Source #
Instance details

Defined in Basement.Types.OffsetSize

type Difference ( CountOf ty) Source #
Instance details

Defined in Basement.Types.OffsetSize

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 #