Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
newtype I (sign :: ISign) (size :: ISize) (e :: Endianness) Source #
Wrapper type grouping machine integers (sign, size) along with an explicit endianness.
The internal representation is selected via a type family to correspond to the relevant Haskell data type, so common overflow behaviour should match. We derive lots of handy instances, so you may perform regular arithmetic on pairs of these types. For example:
>>>
255 + 1 :: I 'U 'I1 e
0
>>>
255 + 1 :: I 'U 'I2 e
256
Instances
FromJSON (IRep sign size) => FromJSON (I sign size e) Source # | |
ToJSON (IRep sign size) => ToJSON (I sign size e) Source # | |
Defined in Binrep.Type.Int | |
(Data (IRep sign size), Typeable sign, Typeable size, Typeable e) => Data (I sign size e) Source # | |
Defined in Binrep.Type.Int gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> I sign size e -> c (I sign size e) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (I sign size e) # toConstr :: I sign size e -> Constr # dataTypeOf :: I sign size e -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (I sign size e)) # dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (I sign size e)) # gmapT :: (forall b. Data b => b -> b) -> I sign size e -> I sign size e # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> I sign size e -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> I sign size e -> r # gmapQ :: (forall d. Data d => d -> u) -> I sign size e -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> I sign size e -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> I sign size e -> m (I sign size e) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> I sign size e -> m (I sign size e) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> I sign size e -> m (I sign size e) # | |
Bounded (IRep sign size) => Bounded (I sign size e) Source # | |
Enum (IRep sign size) => Enum (I sign size e) Source # | |
Defined in Binrep.Type.Int succ :: I sign size e -> I sign size e # pred :: I sign size e -> I sign size e # toEnum :: Int -> I sign size e # fromEnum :: I sign size e -> Int # enumFrom :: I sign size e -> [I sign size e] # enumFromThen :: I sign size e -> I sign size e -> [I sign size e] # enumFromTo :: I sign size e -> I sign size e -> [I sign size e] # enumFromThenTo :: I sign size e -> I sign size e -> I sign size e -> [I sign size e] # | |
Generic (I sign size e) Source # | |
Num (IRep sign size) => Num (I sign size e) Source # | |
Defined in Binrep.Type.Int (+) :: I sign size e -> I sign size e -> I sign size e # (-) :: I sign size e -> I sign size e -> I sign size e # (*) :: I sign size e -> I sign size e -> I sign size e # negate :: I sign size e -> I sign size e # abs :: I sign size e -> I sign size e # signum :: I sign size e -> I sign size e # fromInteger :: Integer -> I sign size e # | |
Integral (IRep sign size) => Integral (I sign size e) Source # | |
Defined in Binrep.Type.Int quot :: I sign size e -> I sign size e -> I sign size e # rem :: I sign size e -> I sign size e -> I sign size e # div :: I sign size e -> I sign size e -> I sign size e # mod :: I sign size e -> I sign size e -> I sign size e # quotRem :: I sign size e -> I sign size e -> (I sign size e, I sign size e) # divMod :: I sign size e -> I sign size e -> (I sign size e, I sign size e) # | |
Real (IRep sign size) => Real (I sign size e) Source # | |
Defined in Binrep.Type.Int toRational :: I sign size e -> Rational # | |
Show (IRep sign size) => Show (I sign size e) Source # | |
KnownNat (CBLen (I sign size end)) => BLen (I sign size end) Source # | |
Get (I 'S 'I1 e) Source # | |
Get (I 'S 'I2 'BE) Source # | |
Get (I 'S 'I2 'LE) Source # | |
Get (I 'S 'I4 'BE) Source # | |
Get (I 'S 'I4 'LE) Source # | |
Get (I 'S 'I8 'BE) Source # | |
Get (I 'S 'I8 'LE) Source # | |
Get (I 'U 'I1 e) Source # | |
Get (I 'U 'I2 'BE) Source # | |
Get (I 'U 'I2 'LE) Source # | |
Get (I 'U 'I4 'BE) Source # | |
Get (I 'U 'I4 'LE) Source # | |
Get (I 'U 'I8 'BE) Source # | |
Get (I 'U 'I8 'LE) Source # | |
Put (I 'S 'I1 e) Source # | |
Put (I 'S 'I2 'BE) Source # | |
Put (I 'S 'I2 'LE) Source # | |
Put (I 'S 'I4 'BE) Source # | |
Put (I 'S 'I4 'LE) Source # | |
Put (I 'S 'I8 'BE) Source # | |
Put (I 'S 'I8 'LE) Source # | |
Put (I 'U 'I1 e) Source # | |
Put (I 'U 'I2 'BE) Source # | |
Put (I 'U 'I2 'LE) Source # | |
Put (I 'U 'I4 'BE) Source # | |
Put (I 'U 'I4 'LE) Source # | |
Put (I 'U 'I8 'BE) Source # | |
Put (I 'U 'I8 'LE) Source # | |
Eq (IRep sign size) => Eq (I sign size e) Source # | |
Ord (IRep sign size) => Ord (I sign size e) Source # | |
Defined in Binrep.Type.Int compare :: I sign size e -> I sign size e -> Ordering # (<) :: I sign size e -> I sign size e -> Bool # (<=) :: I sign size e -> I sign size e -> Bool # (>) :: I sign size e -> I sign size e -> Bool # (>=) :: I sign size e -> I sign size e -> Bool # | |
(irep ~ IRep 'S size, Integral irep, Bounded irep, Show irep, Typeable size, Typeable end) => Strengthen (I 'S size end) Source # | |
Defined in Binrep.Type.Int strengthen :: Weak (I 'S size end) -> Validation (NonEmpty StrengthenFail) (I 'S size end) # | |
(irep ~ IRep 'U size, Integral irep, Bounded irep, Show irep, Typeable size, Typeable end) => Strengthen (I 'U size end) Source # | |
Defined in Binrep.Type.Int strengthen :: Weak (I 'U size end) -> Validation (NonEmpty StrengthenFail) (I 'U size end) # | |
(irep ~ IRep 'S size, Integral irep) => Weaken (I 'S size end) Source # | Signed machine integers can be idealized as integers. |
(irep ~ IRep 'U size, Integral irep) => Weaken (I 'U size end) Source # | Unsigned machine integers can be idealized as naturals. |
type Rep (I sign size e) Source # | |
Defined in Binrep.Type.Int | |
type CBLen (I sign size end) Source # | |
Defined in Binrep.Type.Int | |
type Weak (I 'S size end) Source # | |
Defined in Binrep.Type.Int | |
type Weak (I 'U size end) Source # | |
Defined in Binrep.Type.Int |
Machine integer sign.
Instances
Data ISign Source # | |
Defined in Binrep.Type.Int gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ISign -> c ISign # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ISign # dataTypeOf :: ISign -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ISign) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ISign) # gmapT :: (forall b. Data b => b -> b) -> ISign -> ISign # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ISign -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ISign -> r # gmapQ :: (forall d. Data d => d -> u) -> ISign -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ISign -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ISign -> m ISign # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ISign -> m ISign # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ISign -> m ISign # | |
Generic ISign Source # | |
Show ISign Source # | |
Eq ISign Source # | |
type Rep ISign Source # | |
Machine integer size in number of bytes.
Instances
Data ISize Source # | |
Defined in Binrep.Type.Int gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ISize -> c ISize # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ISize # dataTypeOf :: ISize -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ISize) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ISize) # gmapT :: (forall b. Data b => b -> b) -> ISize -> ISize # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ISize -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ISize -> r # gmapQ :: (forall d. Data d => d -> u) -> ISize -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ISize -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ISize -> m ISize # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ISize -> m ISize # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ISize -> m ISize # | |
Generic ISize Source # | |
Show ISize Source # | |
Eq ISize Source # | |
type Rep ISize Source # | |
Defined in Binrep.Type.Int type Rep ISize = D1 ('MetaData "ISize" "Binrep.Type.Int" "binrep-0.3.0-inplace" 'False) ((C1 ('MetaCons "I1" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "I2" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "I4" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "I8" 'PrefixI 'False) (U1 :: Type -> Type))) |
type family IRep (sign :: ISign) (size :: ISize) where ... Source #
Grouping for matching a signedness and size to a Haskell integer data type.