{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MagicHash #-}
module Haskus.Number.Int
( IntAtLeast
, IntN
, module GHC.Int
, Int#
, (+#)
, (-#)
, (==#)
, (>#)
, (<#)
, (>=#)
, (<=#)
, isTrue#
)
where
import Data.Int
import GHC.Int
import GHC.Exts
import Haskus.Utils.Types
type family IntAtLeast (n :: Nat) where
IntAtLeast n =
If (n <=? 8) Int8
(If (n <=? 16) Int16
(If (n <=? 32) Int32
(Assert (n <=? 64) Int64
('Text "Cannot find Int with size " ':<>: 'ShowType n)
)))
type family IntN (n :: Nat) where
IntN 8 = Int8
IntN 16 = Int16
IntN 32 = Int32
IntN 64 = Int64
IntN n = TypeError ('Text "Cannot find Int with size " ':<>: 'ShowType n)