basement-0.0.1: Foundation scrap box of array & string

LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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

IntegralCast Int (Offset ty) Source # 

Methods

integralCast :: Int -> Offset ty Source #

IntegralCast Word (Offset ty) Source # 

Methods

integralCast :: Word -> Offset ty Source #

Enum (Offset ty) Source # 

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] #

Eq (Offset ty) Source # 

Methods

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

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

Num (Offset ty) Source # 

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 #

Ord (Offset ty) Source # 

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 #

Show (Offset ty) Source # 

Methods

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

show :: Offset ty -> String #

showList :: [Offset ty] -> ShowS #

Integral (Offset ty) Source # 
IsNatural (Offset ty) Source # 

Methods

toNatural :: Offset ty -> Natural Source #

IsIntegral (Offset ty) Source # 

Methods

toInteger :: Offset ty -> Integer Source #

Additive (Offset ty) Source # 

Methods

azero :: Offset ty Source #

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

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

Subtractive (Offset ty) Source # 

Associated Types

type Difference (Offset ty) :: * Source #

Methods

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

NormalForm (Offset a) Source # 

Methods

toNormalForm :: Offset a -> () Source #

type Difference (Offset ty) Source # 
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

IntegralCast Int (CountOf ty) Source # 

Methods

integralCast :: Int -> CountOf ty Source #

IntegralCast Word (CountOf ty) Source # 

Methods

integralCast :: Word -> CountOf ty Source #

Enum (CountOf ty) Source # 

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] #

Eq (CountOf ty) Source # 

Methods

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

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

Num (CountOf ty) Source # 

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 #

Ord (CountOf ty) Source # 

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 #

Show (CountOf ty) Source # 

Methods

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

show :: CountOf ty -> String #

showList :: [CountOf ty] -> ShowS #

Monoid (CountOf ty) Source # 

Methods

mempty :: CountOf ty #

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

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

Integral (CountOf ty) Source # 
IsNatural (CountOf ty) Source # 

Methods

toNatural :: CountOf ty -> Natural Source #

IsIntegral (CountOf ty) Source # 

Methods

toInteger :: CountOf ty -> Integer Source #

Additive (CountOf ty) Source # 

Methods

azero :: CountOf ty Source #

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

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

Subtractive (CountOf ty) Source # 

Associated Types

type Difference (CountOf ty) :: * Source #

Methods

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

NormalForm (CountOf a) Source # 

Methods

toNormalForm :: CountOf a -> () Source #

From (CountOf ty) Word Source # 

Methods

from :: CountOf ty -> Word Source #

From (CountOf ty) Int Source # 

Methods

from :: CountOf ty -> Int Source #

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