Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Foreign.C.Types
Synopsis
Representations of C types
These types are needed to accurately represent C function prototypes,
in order to access C library interfaces in Haskell. The Haskell system
is not required to represent those types exactly as C does, but the
following guarantees are provided concerning a Haskell type CT
representing a C type t
:
- If a C function prototype has
t
as an argument or result type, the use ofCT
in the corresponding position in a foreign declaration permits the Haskell program to access the full range of values encoded by the C type; and conversely, any Haskell value forCT
has a valid representation in C.
will yield the same value assizeOf
(undefined
:: CT)sizeof (t)
in C.
matches the alignment constraint enforced by the C implementation foralignment
(undefined
:: CT)t
.- The members
peek
andpoke
of theStorable
class map all values ofCT
to the corresponding value oft
and vice versa. - When an instance of
Bounded
is defined forCT
, the values ofminBound
andmaxBound
coincide witht_MIN
andt_MAX
in C. - When an instance of
Eq
orOrd
is defined forCT
, the predicates defined by the type class implement the same relation as the corresponding predicate in C ont
. - When an instance of
Num
,Read
,Integral
,Fractional
,Floating
,RealFrac
, orRealFloat
is defined forCT
, the arithmetic operations defined by the type class implement the same function as the corresponding arithmetic operations (if available) in C ont
. - When an instance of
Bits
is defined forCT
, the bitwise operation defined by the type class implement the same function as the corresponding bitwise operation in C ont
.
Integral types
These types are are represented as newtype
s of
types in Data.Int and Data.Word, and are instances of
Eq
, Ord
, Num
, Read
,
Show
, Enum
, Storable
,
Bounded
, Real
, Integral
and
Bits
.
Haskell type representing the C char
type.
Instances
Bounded CChar | |
Enum CChar | |
Defined in Foreign.C.Types | |
Eq CChar | |
Integral CChar | |
Num CChar | |
Ord CChar | |
Read CChar | |
Real CChar | |
Defined in Foreign.C.Types Methods toRational :: CChar -> Rational # | |
Show CChar | |
Storable CChar | |
Bits CChar | |
Defined in Foreign.C.Types Methods (.&.) :: CChar -> CChar -> CChar # (.|.) :: CChar -> CChar -> CChar # xor :: CChar -> CChar -> CChar # complement :: CChar -> CChar # shift :: CChar -> Int -> CChar # rotate :: CChar -> Int -> CChar # setBit :: CChar -> Int -> CChar # clearBit :: CChar -> Int -> CChar # complementBit :: CChar -> Int -> CChar # testBit :: CChar -> Int -> Bool # bitSizeMaybe :: CChar -> Maybe Int # shiftL :: CChar -> Int -> CChar # unsafeShiftL :: CChar -> Int -> CChar # shiftR :: CChar -> Int -> CChar # unsafeShiftR :: CChar -> Int -> CChar # rotateL :: CChar -> Int -> CChar # | |
FiniteBits CChar | |
Defined in Foreign.C.Types Methods finiteBitSize :: CChar -> Int # countLeadingZeros :: CChar -> Int # countTrailingZeros :: CChar -> Int # |
Haskell type representing the C signed char
type.
Instances
Haskell type representing the C unsigned char
type.
Instances
Haskell type representing the C short
type.
Instances
Haskell type representing the C unsigned short
type.
Instances
Haskell type representing the C int
type.
Instances
Bounded CInt | |
Enum CInt | |
Eq CInt | |
Integral CInt | |
Num CInt | |
Ord CInt | |
Read CInt | |
Real CInt | |
Defined in Foreign.C.Types Methods toRational :: CInt -> Rational # | |
Show CInt | |
Storable CInt | |
Defined in Foreign.C.Types | |
Bits CInt | |
Defined in Foreign.C.Types Methods (.&.) :: CInt -> CInt -> CInt # (.|.) :: CInt -> CInt -> CInt # complement :: CInt -> CInt # shift :: CInt -> Int -> CInt # rotate :: CInt -> Int -> CInt # setBit :: CInt -> Int -> CInt # clearBit :: CInt -> Int -> CInt # complementBit :: CInt -> Int -> CInt # testBit :: CInt -> Int -> Bool # bitSizeMaybe :: CInt -> Maybe Int # shiftL :: CInt -> Int -> CInt # unsafeShiftL :: CInt -> Int -> CInt # shiftR :: CInt -> Int -> CInt # unsafeShiftR :: CInt -> Int -> CInt # rotateL :: CInt -> Int -> CInt # | |
FiniteBits CInt | |
Defined in Foreign.C.Types Methods finiteBitSize :: CInt -> Int # countLeadingZeros :: CInt -> Int # countTrailingZeros :: CInt -> Int # |
Haskell type representing the C unsigned int
type.
Instances
Bounded CUInt | |
Enum CUInt | |
Defined in Foreign.C.Types | |
Eq CUInt | |
Integral CUInt | |
Num CUInt | |
Ord CUInt | |
Read CUInt | |
Real CUInt | |
Defined in Foreign.C.Types Methods toRational :: CUInt -> Rational # | |
Show CUInt | |
Storable CUInt | |
Bits CUInt | |
Defined in Foreign.C.Types Methods (.&.) :: CUInt -> CUInt -> CUInt # (.|.) :: CUInt -> CUInt -> CUInt # xor :: CUInt -> CUInt -> CUInt # complement :: CUInt -> CUInt # shift :: CUInt -> Int -> CUInt # rotate :: CUInt -> Int -> CUInt # setBit :: CUInt -> Int -> CUInt # clearBit :: CUInt -> Int -> CUInt # complementBit :: CUInt -> Int -> CUInt # testBit :: CUInt -> Int -> Bool # bitSizeMaybe :: CUInt -> Maybe Int # shiftL :: CUInt -> Int -> CUInt # unsafeShiftL :: CUInt -> Int -> CUInt # shiftR :: CUInt -> Int -> CUInt # unsafeShiftR :: CUInt -> Int -> CUInt # rotateL :: CUInt -> Int -> CUInt # | |
FiniteBits CUInt | |
Defined in Foreign.C.Types Methods finiteBitSize :: CUInt -> Int # countLeadingZeros :: CUInt -> Int # countTrailingZeros :: CUInt -> Int # |
Haskell type representing the C long
type.
Instances
Bounded CLong | |
Enum CLong | |
Defined in Foreign.C.Types | |
Eq CLong | |
Integral CLong | |
Num CLong | |
Ord CLong | |
Read CLong | |
Real CLong | |
Defined in Foreign.C.Types Methods toRational :: CLong -> Rational # | |
Show CLong | |
Storable CLong | |
Bits CLong | |
Defined in Foreign.C.Types Methods (.&.) :: CLong -> CLong -> CLong # (.|.) :: CLong -> CLong -> CLong # xor :: CLong -> CLong -> CLong # complement :: CLong -> CLong # shift :: CLong -> Int -> CLong # rotate :: CLong -> Int -> CLong # setBit :: CLong -> Int -> CLong # clearBit :: CLong -> Int -> CLong # complementBit :: CLong -> Int -> CLong # testBit :: CLong -> Int -> Bool # bitSizeMaybe :: CLong -> Maybe Int # shiftL :: CLong -> Int -> CLong # unsafeShiftL :: CLong -> Int -> CLong # shiftR :: CLong -> Int -> CLong # unsafeShiftR :: CLong -> Int -> CLong # rotateL :: CLong -> Int -> CLong # | |
FiniteBits CLong | |
Defined in Foreign.C.Types Methods finiteBitSize :: CLong -> Int # countLeadingZeros :: CLong -> Int # countTrailingZeros :: CLong -> Int # |
Haskell type representing the C unsigned long
type.
Instances
Haskell type representing the C ptrdiff_t
type.
Instances
Haskell type representing the C size_t
type.
Instances
Bounded CSize | |
Enum CSize | |
Defined in Foreign.C.Types | |
Eq CSize | |
Integral CSize | |
Num CSize | |
Ord CSize | |
Read CSize | |
Real CSize | |
Defined in Foreign.C.Types Methods toRational :: CSize -> Rational # | |
Show CSize | |
Storable CSize | |
Bits CSize | |
Defined in Foreign.C.Types Methods (.&.) :: CSize -> CSize -> CSize # (.|.) :: CSize -> CSize -> CSize # xor :: CSize -> CSize -> CSize # complement :: CSize -> CSize # shift :: CSize -> Int -> CSize # rotate :: CSize -> Int -> CSize # setBit :: CSize -> Int -> CSize # clearBit :: CSize -> Int -> CSize # complementBit :: CSize -> Int -> CSize # testBit :: CSize -> Int -> Bool # bitSizeMaybe :: CSize -> Maybe Int # shiftL :: CSize -> Int -> CSize # unsafeShiftL :: CSize -> Int -> CSize # shiftR :: CSize -> Int -> CSize # unsafeShiftR :: CSize -> Int -> CSize # rotateL :: CSize -> Int -> CSize # | |
FiniteBits CSize | |
Defined in Foreign.C.Types Methods finiteBitSize :: CSize -> Int # countLeadingZeros :: CSize -> Int # countTrailingZeros :: CSize -> Int # |
Haskell type representing the C wchar_t
type.
Instances
data CSigAtomic #
Haskell type representing the C sig_atomic_t
type.
Instances
Haskell type representing the C long long
type.
Instances
Haskell type representing the C unsigned long long
type.
Instances
Instances
Instances
Instances
Instances
Numeric types
These types are are represented as newtype
s of basic
foreign types, and are instances of
Eq
, Ord
, Num
, Read
,
Show
, Enum
and Storable
.
Haskell type representing the C clock_t
type.
Instances
Enum CClock | |
Defined in Foreign.C.Types | |
Eq CClock | |
Num CClock | |
Ord CClock | |
Read CClock | |
Real CClock | |
Defined in Foreign.C.Types Methods toRational :: CClock -> Rational # | |
Show CClock | |
Storable CClock | |
Haskell type representing the C time_t
type.
Instances
Enum CTime | |
Defined in Foreign.C.Types | |
Eq CTime | |
Num CTime | |
Ord CTime | |
Read CTime | |
Real CTime | |
Defined in Foreign.C.Types Methods toRational :: CTime -> Rational # | |
Show CTime | |
Storable CTime | |
Floating types
These types are are represented as newtype
s of
Float
and Double
, and are instances of
Eq
, Ord
, Num
, Read
,
Show
, Enum
, Storable
,
Real
, Fractional
, Floating
,
RealFrac
and RealFloat
.
Haskell type representing the C float
type.
Instances
Enum CFloat | |
Defined in Foreign.C.Types | |
Eq CFloat | |
Floating CFloat | |
Fractional CFloat | |
Num CFloat | |
Ord CFloat | |
Read CFloat | |
Real CFloat | |
Defined in Foreign.C.Types Methods toRational :: CFloat -> Rational # | |
RealFloat CFloat | |
Defined in Foreign.C.Types Methods floatRadix :: CFloat -> Integer # floatDigits :: CFloat -> Int # floatRange :: CFloat -> (Int, Int) # decodeFloat :: CFloat -> (Integer, Int) # encodeFloat :: Integer -> Int -> CFloat # significand :: CFloat -> CFloat # scaleFloat :: Int -> CFloat -> CFloat # isInfinite :: CFloat -> Bool # isDenormalized :: CFloat -> Bool # isNegativeZero :: CFloat -> Bool # | |
RealFrac CFloat | |
Show CFloat | |
Storable CFloat | |
Haskell type representing the C double
type.
Instances
Enum CDouble | |
Eq CDouble | |
Floating CDouble | |
Fractional CDouble | |
Num CDouble | |
Ord CDouble | |
Read CDouble | |
Real CDouble | |
Defined in Foreign.C.Types Methods toRational :: CDouble -> Rational # | |
RealFloat CDouble | |
Defined in Foreign.C.Types Methods floatRadix :: CDouble -> Integer # floatDigits :: CDouble -> Int # floatRange :: CDouble -> (Int, Int) # decodeFloat :: CDouble -> (Integer, Int) # encodeFloat :: Integer -> Int -> CDouble # significand :: CDouble -> CDouble # scaleFloat :: Int -> CDouble -> CDouble # isInfinite :: CDouble -> Bool # isDenormalized :: CDouble -> Bool # isNegativeZero :: CDouble -> Bool # | |
RealFrac CDouble | |
Show CDouble | |
Storable CDouble | |