{-# LANGUAGE CPP #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
#include <MachDeps.h>
#include <HsBaseConfig.h>
module I.Internal where
import Data.Coerce
import Data.Constraint
import Data.Kind
import Data.Int
import Data.Maybe
import Data.Proxy
import Data.Word
import Data.Type.Equality
import Foreign.C.Types
import GHC.TypeLits qualified as L
import GHC.Stack
import KindInteger qualified as KI
import KindRational qualified as KR
import Prelude hiding (min, max, div, pred, succ, recip, negate)
import Unsafe.Coerce (unsafeCoerce)
leNatural
:: forall a b
. (L.KnownNat a, L.KnownNat b)
=> Maybe (Dict (a L.<= b))
leNatural :: forall (a :: Nat) (b :: Nat).
(KnownNat a, KnownNat b) =>
Maybe (Dict (a <= b))
leNatural = case Proxy a -> Proxy b -> OrderingI a b
forall (a :: Nat) (b :: Nat) (proxy1 :: Nat -> *)
(proxy2 :: Nat -> *).
(KnownNat a, KnownNat b) =>
proxy1 a -> proxy2 b -> OrderingI a b
L.cmpNat (forall (t :: Nat). Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) (forall (t :: Nat). Proxy t
forall {k} (t :: k). Proxy t
Proxy @b) of
OrderingI a b
L.LTI -> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a. a -> Maybe a
Just (Dict (a <= b) -> Maybe (Dict (a <= b)))
-> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a b. (a -> b) -> a -> b
$ Dict (() :: Constraint) -> Dict (() :: Constraint)
forall a b. a -> b
unsafeCoerce (forall (a :: Constraint). a => Dict a
Dict @())
OrderingI a b
L.EQI -> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a. a -> Maybe a
Just (Dict (a <= b) -> Maybe (Dict (a <= b)))
-> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a b. (a -> b) -> a -> b
$ Dict (() :: Constraint) -> Dict (() :: Constraint)
forall a b. a -> b
unsafeCoerce (forall (a :: Constraint). a => Dict a
Dict @())
OrderingI a b
L.GTI -> Maybe (Dict (TypeError ...))
Maybe (Dict (a <= b))
forall a. Maybe a
Nothing
leInteger
:: forall (a :: KI.Integer) (b :: KI.Integer)
. (KI.KnownInteger a, KI.KnownInteger b)
=> Maybe (Dict (a L.<= b))
leInteger :: forall (a :: Integer) (b :: Integer).
(KnownInteger a, KnownInteger b) =>
Maybe (Dict (a <= b))
leInteger = case Proxy a -> Proxy b -> OrderingI a b
forall (a :: Integer) (b :: Integer) (proxy1 :: Integer -> *)
(proxy2 :: Integer -> *).
(KnownInteger a, KnownInteger b) =>
proxy1 a -> proxy2 b -> OrderingI a b
KI.cmpInteger (forall {k} (t :: k). Proxy t
forall (t :: Integer). Proxy t
Proxy @a) (forall {k} (t :: k). Proxy t
forall (t :: Integer). Proxy t
Proxy @b) of
OrderingI a b
L.LTI -> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a. a -> Maybe a
Just (Dict (a <= b) -> Maybe (Dict (a <= b)))
-> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a b. (a -> b) -> a -> b
$ Dict (() :: Constraint) -> Dict (() :: Constraint)
forall a b. a -> b
unsafeCoerce (forall (a :: Constraint). a => Dict a
Dict @())
OrderingI a b
L.EQI -> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a. a -> Maybe a
Just (Dict (a <= b) -> Maybe (Dict (a <= b)))
-> Dict (a <= b) -> Maybe (Dict (a <= b))
forall a b. (a -> b) -> a -> b
$ Dict (() :: Constraint) -> Dict (() :: Constraint)
forall a b. a -> b
unsafeCoerce (forall (a :: Constraint). a => Dict a
Dict @())
OrderingI a b
L.GTI -> Maybe (Dict (TypeError ...))
Maybe (Dict (a <= b))
forall a. Maybe a
Nothing
type role I nominal nominal nominal
newtype I (x :: Type) (l :: L x) (r :: R x) = UnsafeI x
deriving newtype (I x l r -> I x l r -> Bool
(I x l r -> I x l r -> Bool)
-> (I x l r -> I x l r -> Bool) -> Eq (I x l r)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall x (l :: L x) (r :: R x). Eq x => I x l r -> I x l r -> Bool
$c== :: forall x (l :: L x) (r :: R x). Eq x => I x l r -> I x l r -> Bool
== :: I x l r -> I x l r -> Bool
$c/= :: forall x (l :: L x) (r :: R x). Eq x => I x l r -> I x l r -> Bool
/= :: I x l r -> I x l r -> Bool
Eq, Eq (I x l r)
Eq (I x l r)
-> (I x l r -> I x l r -> Ordering)
-> (I x l r -> I x l r -> Bool)
-> (I x l r -> I x l r -> Bool)
-> (I x l r -> I x l r -> Bool)
-> (I x l r -> I x l r -> Bool)
-> (I x l r -> I x l r -> I x l r)
-> (I x l r -> I x l r -> I x l r)
-> Ord (I x l r)
I x l r -> I x l r -> Bool
I x l r -> I x l r -> Ordering
I x l r -> I x l r -> I x l r
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {x} {l :: L x} {r :: R x}. Ord x => Eq (I x l r)
forall x (l :: L x) (r :: R x). Ord x => I x l r -> I x l r -> Bool
forall x (l :: L x) (r :: R x).
Ord x =>
I x l r -> I x l r -> Ordering
forall x (l :: L x) (r :: R x).
Ord x =>
I x l r -> I x l r -> I x l r
$ccompare :: forall x (l :: L x) (r :: R x).
Ord x =>
I x l r -> I x l r -> Ordering
compare :: I x l r -> I x l r -> Ordering
$c< :: forall x (l :: L x) (r :: R x). Ord x => I x l r -> I x l r -> Bool
< :: I x l r -> I x l r -> Bool
$c<= :: forall x (l :: L x) (r :: R x). Ord x => I x l r -> I x l r -> Bool
<= :: I x l r -> I x l r -> Bool
$c> :: forall x (l :: L x) (r :: R x). Ord x => I x l r -> I x l r -> Bool
> :: I x l r -> I x l r -> Bool
$c>= :: forall x (l :: L x) (r :: R x). Ord x => I x l r -> I x l r -> Bool
>= :: I x l r -> I x l r -> Bool
$cmax :: forall x (l :: L x) (r :: R x).
Ord x =>
I x l r -> I x l r -> I x l r
max :: I x l r -> I x l r -> I x l r
$cmin :: forall x (l :: L x) (r :: R x).
Ord x =>
I x l r -> I x l r -> I x l r
min :: I x l r -> I x l r -> I x l r
Ord, Int -> I x l r -> ShowS
[I x l r] -> ShowS
I x l r -> String
(Int -> I x l r -> ShowS)
-> (I x l r -> String) -> ([I x l r] -> ShowS) -> Show (I x l r)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall x (l :: L x) (r :: R x). Show x => Int -> I x l r -> ShowS
forall x (l :: L x) (r :: R x). Show x => [I x l r] -> ShowS
forall x (l :: L x) (r :: R x). Show x => I x l r -> String
$cshowsPrec :: forall x (l :: L x) (r :: R x). Show x => Int -> I x l r -> ShowS
showsPrec :: Int -> I x l r -> ShowS
$cshow :: forall x (l :: L x) (r :: R x). Show x => I x l r -> String
show :: I x l r -> String
$cshowList :: forall x (l :: L x) (r :: R x). Show x => [I x l r] -> ShowS
showList :: [I x l r] -> ShowS
Show)
type family T (x :: Type) :: k
type family MinT (x :: Type) :: T x
type family MaxT (x :: Type) :: T x
type family L (x :: Type) :: k
type family MinL (x :: Type) :: L x
type family R (x :: Type) :: k
type family MaxR (x :: Type) :: R x
class IntervalCtx x l r => Interval (x :: Type) (l :: L x) (r :: R x) where
type IntervalCtx x l r :: Constraint
type IntervalCtx x l r = ()
type MinI x l r :: T x
type MinI x l r = L.TypeError
('L.Text "MinI not defined in instance ‘" 'L.:<>:
'L.ShowType (Interval x l r) 'L.:<>: 'L.Text "’")
type MaxI x l r :: T x
type MaxI x l r = L.TypeError
('L.Text "MaxI not defined in instance ‘" 'L.:<>:
'L.ShowType (Interval x l r) 'L.:<>: 'L.Text "’")
inhabitant :: I x l r
from :: x -> Maybe (I x l r)
plus' :: I x l r -> I x l r -> Maybe (I x l r)
plus' I x l r
_ I x l r
_ = Maybe (I x l r)
forall a. Maybe a
Nothing
mult' :: I x l r -> I x l r -> Maybe (I x l r)
mult' I x l r
_ I x l r
_ = Maybe (I x l r)
forall a. Maybe a
Nothing
minus' :: I x l r -> I x l r -> Maybe (I x l r)
minus' I x l r
a I x l r
b = I x l r -> I x l r -> Maybe (I x l r)
forall x (l :: L x) (r :: R x).
Interval x l r =>
I x l r -> I x l r -> Maybe (I x l r)
plus' I x l r
a (I x l r -> Maybe (I x l r)) -> Maybe (I x l r) -> Maybe (I x l r)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< I x l r -> Maybe (I x l r)
forall x (l :: L x) (r :: R x).
Interval x l r =>
I x l r -> Maybe (I x l r)
negate' I x l r
b
{-# INLINE minus' #-}
negate' :: I x l r -> Maybe (I x l r)
negate' I x l r
_ = Maybe (I x l r)
forall a. Maybe a
Nothing
recip' :: I x l r -> Maybe (I x l r)
recip' I x l r
_ = Maybe (I x l r)
forall a. Maybe a
Nothing
div' :: I x l r -> I x l r -> Maybe (I x l r)
div' I x l r
a I x l r
b = I x l r -> I x l r -> Maybe (I x l r)
forall x (l :: L x) (r :: R x).
Interval x l r =>
I x l r -> I x l r -> Maybe (I x l r)
mult' I x l r
a (I x l r -> Maybe (I x l r)) -> Maybe (I x l r) -> Maybe (I x l r)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< I x l r -> Maybe (I x l r)
forall x (l :: L x) (r :: R x).
Interval x l r =>
I x l r -> Maybe (I x l r)
recip' I x l r
b
{-# INLINE div' #-}
unsafe :: forall x l r. (HasCallStack, Interval x l r) => x -> I x l r
unsafe :: forall x (l :: L x) (r :: R x).
(HasCallStack, Interval x l r) =>
x -> I x l r
unsafe = I x l r -> Maybe (I x l r) -> I x l r
forall a. a -> Maybe a -> a
fromMaybe (String -> I x l r
forall a. HasCallStack => String -> a
error String
"I.unsafe: input outside interval") (Maybe (I x l r) -> I x l r)
-> (x -> Maybe (I x l r)) -> x -> I x l r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. x -> Maybe (I x l r)
forall x (l :: L x) (r :: R x).
Interval x l r =>
x -> Maybe (I x l r)
from
{-# INLINE unsafe #-}
unsafest :: forall x l r. x -> I x l r
unsafest :: forall x (l :: L x) (r :: R x). x -> I x l r
unsafest = x -> I x l r
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unsafest #-}
class (Interval x l r) => Clamp (x :: Type) (l :: L x) (r :: R x) where
clamp :: x -> I x l r
default clamp
:: ( Known x l r (MinI x l r)
, Known x l r (MaxI x l r)
, Ord x )
=> x
-> I x l r
clamp = \case
x
x | x
x x -> x -> Bool
forall a. Ord a => a -> a -> Bool
<= I x l r -> x
forall x (l :: L x) (r :: R x). I x l r -> x
unwrap I x l r
min_ -> I x l r
min_
| x
x x -> x -> Bool
forall a. Ord a => a -> a -> Bool
>= I x l r -> x
forall x (l :: L x) (r :: R x). I x l r -> x
unwrap I x l r
max_ -> I x l r
max_
| Bool
otherwise -> x -> I x l r
forall x (l :: L x) (r :: R x).
(HasCallStack, Interval x l r) =>
x -> I x l r
unsafe x
x
where min_ :: I x l r
min_ = I x l r
forall x (l :: L x) (r :: R x). Known x l r (MinI x l r) => I x l r
min
max_ :: I x l r
max_ = I x l r
forall x (l :: L x) (r :: R x). Known x l r (MaxI x l r) => I x l r
max
down :: forall x lu ru ld rd
. (Interval x ld rd)
=> I x lu ru
-> Maybe (I x ld rd)
down :: forall x (lu :: L x) (ru :: R x) (ld :: L x) (rd :: R x).
Interval x ld rd =>
I x lu ru -> Maybe (I x ld rd)
down = x -> Maybe (I x ld rd)
forall x (l :: L x) (r :: R x).
Interval x l r =>
x -> Maybe (I x l r)
from (x -> Maybe (I x ld rd))
-> (I x lu ru -> x) -> I x lu ru -> Maybe (I x ld rd)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. I x lu ru -> x
forall x (l :: L x) (r :: R x). I x l r -> x
unwrap
{-# INLINE down #-}
class
( Interval x ld rd
, Interval x lu ru
) => Up (x :: Type) (ld :: L x) (rd :: R x) (lu :: L x) (ru :: R x)
where
up :: I x ld rd -> I x lu ru
default up :: HasCallStack => I x ld rd -> I x lu ru
up = x -> I x lu ru
forall x (l :: L x) (r :: R x).
(HasCallStack, Interval x l r) =>
x -> I x l r
unsafe (x -> I x lu ru) -> (I x ld rd -> x) -> I x ld rd -> I x lu ru
forall b c a. (b -> c) -> (a -> b) -> a -> c
. I x ld rd -> x
forall x (l :: L x) (r :: R x). I x l r -> x
unwrap
{-# INLINE up #-}
instance {-# INCOHERENT #-} (Interval x l r) => Up x l r l r where
up :: I x l r -> I x l r
up = x -> I x l r
forall x (l :: L x) (r :: R x). x -> I x l r
unsafest (x -> I x l r) -> (I x l r -> x) -> I x l r -> I x l r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. I x l r -> x
forall x (l :: L x) (r :: R x). I x l r -> x
unwrap
{-# INLINE up #-}
class (Interval x l r) => Discrete (x :: Type) (l :: L x) (r :: R x) where
pred' :: I x l r -> Maybe (I x l r)
succ' :: I x l r -> Maybe (I x l r)
class (Interval x l r) => Zero (x :: Type) (l :: L x) (r :: R x) where
zero :: I x l r
class (Interval x l r) => One (x :: Type) (l :: L x) (r :: R x) where
one :: I x l r
class (Interval x l r) => Plus (x :: Type) (l :: L x) (r :: R x) where
plus :: I x l r -> I x l r -> I x l r
class (Interval x l r) => Mult (x :: Type) (l :: L x) (r :: R x) where
mult :: I x l r -> I x l r -> I x l r
class (Zero x l r) => Minus (x :: Type) (l :: L x) (r :: R x) where
minus :: I x l r -> I x l r -> I x l r
class (Zero x l r) => Negate (x :: Type) (l :: L x) (r :: R x) where
negate :: I x l r -> I x l r
class (Discrete x l r) => Pred (x :: Type) (l :: L x) (r :: R x) where
pred :: I x l r -> I x l r
class (Discrete x l r) => Succ (x :: Type) (l :: L x) (r :: R x) where
succ :: I x l r -> I x l r
class (Interval x l r) => Div (x :: Type) (l :: L x) (r :: R x) where
div :: I x l r -> I x l r -> I x l r
single
:: forall x l r
. ( MinI x l r ~ MaxI x l r
, Known x l r (MinI x l r) )
=> I x l r
single :: forall x (l :: L x) (r :: R x).
(MinI x l r ~ MaxI x l r, Known x l r (MinI x l r)) =>
I x l r
single = I x l r
forall x (l :: L x) (r :: R x). Interval x l r => I x l r
inhabitant
{-# INLINE single #-}
class
( Interval x l r, KnownCtx x l r t
) => Known (x :: Type) (l :: L x) (r :: R x) (t :: T x) where
type KnownCtx x l r t :: Constraint
type KnownCtx x l r t = ()
known' :: Proxy t -> I x l r
known :: forall {x} t l r. Known x l r t => I x l r
known :: forall {x} (t :: T x) (l :: L x) (r :: R x).
Known x l r t =>
I x l r
known = Proxy t -> I x l r
forall x (l :: L x) (r :: R x) (t :: T x).
Known x l r t =>
Proxy t -> I x l r
known' (forall {k} (t :: k). Proxy t
forall (t :: T x). Proxy t
Proxy @t)
{-# INLINE known #-}
class (Interval x l r) => With (x :: Type) (l :: L x) (r :: R x) where
with :: I x l r -> (forall (t :: T x). Known x l r t => Proxy t -> b) -> b
wrap :: Interval x (MinL x) (MaxR x) => x -> I x (MinL x) (MaxR x)
wrap :: forall x.
Interval x (MinL x) (MaxR x) =>
x -> I x (MinL x) (MaxR x)
wrap = x -> I x (MinL x) (MaxR x)
forall a b. Coercible a b => a -> b
coerce
{-# INLINE wrap #-}
unwrap :: forall x l r. I x l r -> x
unwrap :: forall x (l :: L x) (r :: R x). I x l r -> x
unwrap = I x l r -> x
forall a b. Coercible a b => a -> b
coerce
{-# INLINE unwrap #-}
min :: forall x l r. Known x l r (MinI x l r) => I x l r
min :: forall x (l :: L x) (r :: R x). Known x l r (MinI x l r) => I x l r
min = forall {x} (t :: T x) (l :: L x) (r :: R x).
Known x l r t =>
I x l r
forall (t :: T x) (l :: L x) (r :: R x). Known x l r t => I x l r
known @(MinI x l r)
max :: forall x l r. Known x l r (MaxI x l r) => I x l r
max :: forall x (l :: L x) (r :: R x). Known x l r (MaxI x l r) => I x l r
max = forall {x} (t :: T x) (l :: L x) (r :: R x).
Known x l r t =>
I x l r
forall (t :: T x) (l :: L x) (r :: R x). Known x l r t => I x l r
known @(MaxI x l r)
instance
( Known x l r (MinI x l r)
, Known x l r (MaxI x l r)
) => Bounded (I x l r) where
minBound :: I x l r
minBound = I x l r
forall x (l :: L x) (r :: R x). Known x l r (MinI x l r) => I x l r
min
maxBound :: I x l r
maxBound = I x l r
forall x (l :: L x) (r :: R x). Known x l r (MaxI x l r) => I x l r
max
class Interval x l r => Shove (x :: Type) (l :: L x) (r :: R x) where
shove :: x -> I x l r
type instance T Word8 = L.Natural
type instance L Word8 = L.Natural
type instance R Word8 = L.Natural
type instance MinT Word8 = 0
type instance MaxT Word8 = 255
type instance T Word16 = L.Natural
type instance L Word16 = L.Natural
type instance R Word16 = L.Natural
type instance MinT Word16 = 0
type instance MaxT Word16 = 65535
type instance T Word32 = L.Natural
type instance L Word32 = L.Natural
type instance R Word32 = L.Natural
type instance MinT Word32 = 0
type instance MaxT Word32 = 4294967295
type instance T Word64 = L.Natural
type instance L Word64 = L.Natural
type instance R Word64 = L.Natural
type instance MinT Word64 = 0
type instance MaxT Word64 = 18446744073709551615
type instance T Word = L.Natural
type instance L Word = L.Natural
type instance R Word = L.Natural
type instance MinT Word = 0
type instance MaxT Word = (2 L.^ WORD_SIZE_IN_BITS) L.- 1
type instance T Int8 = KI.Integer
type instance L Int8 = KI.Integer
type instance R Int8 = KI.Integer
type instance MinT Int8 = KI.N 128
type instance MaxT Int8 = KI.P 127
type instance T Int16 = KI.Integer
type instance L Int16 = KI.Integer
type instance R Int16 = KI.Integer
type instance MinT Int16 = KI.N 32768
type instance MaxT Int16 = KI.P 32767
type instance T Int32 = KI.Integer
type instance L Int32 = KI.Integer
type instance R Int32 = KI.Integer
type instance MinT Int32 = KI.N 2147483648
type instance MaxT Int32 = KI.P 2147483647
type instance T Int64 = KI.Integer
type instance L Int64 = KI.Integer
type instance R Int64 = KI.Integer
type instance MinT Int64 = KI.N 9223372036854775808
type instance MaxT Int64 = KI.P 9223372036854775807
type instance T Int = KI.Integer
type instance L Int = KI.Integer
type instance R Int = KI.Integer
type instance MinT Int = KI.N (L.Div (2 L.^ WORD_SIZE_IN_BITS) 2)
type instance MaxT Int = KI.P (L.Div (2 L.^ WORD_SIZE_IN_BITS) 2 L.- 1)
type instance T CChar = T HTYPE_CHAR
type instance L CChar = L HTYPE_CHAR
type instance R CChar = R HTYPE_CHAR
type instance MinT CChar = MinT HTYPE_CHAR
type instance MaxT CChar = MaxT HTYPE_CHAR
type instance T CSize = T HTYPE_SIZE_T
type instance L CSize = L HTYPE_SIZE_T
type instance R CSize = R HTYPE_SIZE_T
type instance MinT CSize = MinT HTYPE_SIZE_T
type instance MaxT CSize = MaxT HTYPE_SIZE_T
type instance T CClock = T HTYPE_CLOCK_T
type instance L CClock = L HTYPE_CLOCK_T
type instance R CClock = R HTYPE_CLOCK_T
type instance MinT CClock = MinT HTYPE_CLOCK_T
type instance MaxT CClock = MaxT HTYPE_CLOCK_T
type instance T CInt = T HTYPE_INT
type instance L CInt = L HTYPE_INT
type instance R CInt = R HTYPE_INT
type instance MinT CInt = MinT HTYPE_INT
type instance MaxT CInt = MaxT HTYPE_INT
type instance T CIntMax = T HTYPE_INTMAX_T
type instance L CIntMax = L HTYPE_INTMAX_T
type instance R CIntMax = R HTYPE_INTMAX_T
type instance MinT CIntMax = MinT HTYPE_INTMAX_T
type instance MaxT CIntMax = MaxT HTYPE_INTMAX_T
type instance T CIntPtr = T HTYPE_INTPTR_T
type instance L CIntPtr = L HTYPE_INTPTR_T
type instance R CIntPtr = R HTYPE_INTPTR_T
type instance MinT CIntPtr = MinT HTYPE_INTPTR_T
type instance MaxT CIntPtr = MaxT HTYPE_INTPTR_T
type instance T CLLong = T HTYPE_LONG_LONG
type instance L CLLong = L HTYPE_LONG_LONG
type instance R CLLong = R HTYPE_LONG_LONG
type instance MinT CLLong = MinT HTYPE_LONG_LONG
type instance MaxT CLLong = MaxT HTYPE_LONG_LONG
type instance T CLong = T HTYPE_LONG
type instance L CLong = L HTYPE_LONG
type instance R CLong = R HTYPE_LONG
type instance MinT CLong = MinT HTYPE_LONG
type instance MaxT CLong = MaxT HTYPE_LONG
type instance T CPtrdiff = T HTYPE_PTRDIFF_T
type instance L CPtrdiff = L HTYPE_PTRDIFF_T
type instance R CPtrdiff = R HTYPE_PTRDIFF_T
type instance MinT CPtrdiff = MinT HTYPE_PTRDIFF_T
type instance MaxT CPtrdiff = MaxT HTYPE_PTRDIFF_T
type instance T CSChar = T HTYPE_SIGNED_CHAR
type instance L CSChar = L HTYPE_SIGNED_CHAR
type instance R CSChar = R HTYPE_SIGNED_CHAR
type instance MinT CSChar = MinT HTYPE_SIGNED_CHAR
type instance MaxT CSChar = MaxT HTYPE_SIGNED_CHAR
type instance T CSUSeconds = T HTYPE_SUSECONDS_T
type instance L CSUSeconds = L HTYPE_SUSECONDS_T
type instance R CSUSeconds = R HTYPE_SUSECONDS_T
type instance MinT CSUSeconds = MinT HTYPE_SUSECONDS_T
type instance MaxT CSUSeconds = MaxT HTYPE_SUSECONDS_T
type instance T CShort = T HTYPE_SHORT
type instance L CShort = L HTYPE_SHORT
type instance R CShort = R HTYPE_SHORT
type instance MinT CShort = MinT HTYPE_SHORT
type instance MaxT CShort = MaxT HTYPE_SHORT
type instance T CTime = T HTYPE_TIME_T
type instance L CTime = L HTYPE_TIME_T
type instance R CTime = R HTYPE_TIME_T
type instance MinT CTime = MinT HTYPE_TIME_T
type instance MaxT CTime = MaxT HTYPE_TIME_T
type instance T CUChar = T HTYPE_UNSIGNED_CHAR
type instance L CUChar = L HTYPE_UNSIGNED_CHAR
type instance R CUChar = R HTYPE_UNSIGNED_CHAR
type instance MinT CUChar = MinT HTYPE_UNSIGNED_CHAR
type instance MaxT CUChar = MaxT HTYPE_UNSIGNED_CHAR
type instance T CUInt = T HTYPE_UNSIGNED_INT
type instance L CUInt = L HTYPE_UNSIGNED_INT
type instance R CUInt = R HTYPE_UNSIGNED_INT
type instance MinT CUInt = MinT HTYPE_UNSIGNED_INT
type instance MaxT CUInt = MaxT HTYPE_UNSIGNED_INT
type instance T CUIntMax = T HTYPE_UINTMAX_T
type instance L CUIntMax = L HTYPE_UINTMAX_T
type instance R CUIntMax = R HTYPE_UINTMAX_T
type instance MinT CUIntMax = MinT HTYPE_UINTMAX_T
type instance MaxT CUIntMax = MaxT HTYPE_UINTMAX_T
type instance T CUIntPtr = T HTYPE_UINTPTR_T
type instance L CUIntPtr = L HTYPE_UINTPTR_T
type instance R CUIntPtr = R HTYPE_UINTPTR_T
type instance MinT CUIntPtr = MinT HTYPE_UINTPTR_T
type instance MaxT CUIntPtr = MaxT HTYPE_UINTPTR_T
type instance T CULLong = T HTYPE_UNSIGNED_LONG_LONG
type instance L CULLong = L HTYPE_UNSIGNED_LONG_LONG
type instance R CULLong = R HTYPE_UNSIGNED_LONG_LONG
type instance MinT CULLong = MinT HTYPE_UNSIGNED_LONG_LONG
type instance MaxT CULLong = MaxT HTYPE_UNSIGNED_LONG_LONG
type instance T CULong = T HTYPE_UNSIGNED_LONG
type instance L CULong = L HTYPE_UNSIGNED_LONG
type instance R CULong = R HTYPE_UNSIGNED_LONG
type instance MinT CULong = MinT HTYPE_UNSIGNED_LONG
type instance MaxT CULong = MaxT HTYPE_UNSIGNED_LONG
type instance T CUSeconds = T HTYPE_USECONDS_T
type instance L CUSeconds = L HTYPE_USECONDS_T
type instance R CUSeconds = R HTYPE_USECONDS_T
type instance MinT CUSeconds = MinT HTYPE_USECONDS_T
type instance MaxT CUSeconds = MaxT HTYPE_USECONDS_T
type instance T CUShort = T HTYPE_UNSIGNED_SHORT
type instance L CUShort = L HTYPE_UNSIGNED_SHORT
type instance R CUShort = R HTYPE_UNSIGNED_SHORT
type instance MinT CUShort = MinT HTYPE_UNSIGNED_SHORT
type instance MaxT CUShort = MaxT HTYPE_UNSIGNED_SHORT
type instance T CWchar = T HTYPE_WCHAR_T
type instance L CWchar = L HTYPE_WCHAR_T
type instance R CWchar = R HTYPE_WCHAR_T
type instance MinT CWchar = MinT HTYPE_WCHAR_T
type instance MaxT CWchar = MaxT HTYPE_WCHAR_T
type instance T L.Natural = L.Natural
type instance L L.Natural = L.Natural
type instance R L.Natural = Maybe L.Natural
type instance MinT L.Natural = 0
type instance T Integer = KI.Integer
type instance L Integer = Maybe KI.Integer
type instance R Integer = Maybe KI.Integer
type instance T Rational = KR.Rational
type instance L Rational = Maybe (Bool, KR.Rational)
type instance R Rational = Maybe (Bool, KR.Rational)