Haskell Hierarchical Libraries (base package)ContentsIndex
Foreign.C.Types
Portability portable
Stability provisional
Maintainer ffi@haskell.org
Contents
Representations of C types
Integral types
Numeric types
Floating types
Other types
Description
Mapping of C types to corresponding Haskell types.
Synopsis
data CChar
data CSChar
data CUChar
data CShort
data CUShort
data CInt
data CUInt
data CLong
data CULong
data CPtrdiff
data CSize
data CWchar
data CSigAtomic
data CLLong
data CULLong
data CIntPtr
data CUIntPtr
data CIntMax
data CUIntMax
data CClock
data CTime
data CFloat
data CDouble
data CLDouble
data CFile
data CFpos
data CJmpBuf
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 of CT 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 for CT has a valid representation in C.
  • sizeOf (undefined :: CT) will yield the same value as sizeof (t) in C.
  • alignment (undefined :: CT) matches the alignment constraint enforced by the C implementation for t.
  • The members peek and poke of the Storable class map all values of CT to the corresponding value of t and vice versa.
  • When an instance of Bounded is defined for CT, the values of minBound and maxBound coincide with t_MIN and t_MAX in C.
  • When an instance of Eq or Ord is defined for CT, the predicates defined by the type class implement the same relation as the corresponding predicate in C on t.
  • When an instance of Num, Read, Integral, Fractional, Floating, RealFrac, or RealFloat is defined for CT, the arithmetic operations defined by the type class implement the same function as the corresponding arithmetic operations (if available) in C on t.
  • When an instance of Bits is defined for CT, the bitwise operation defined by the type class implement the same function as the corresponding bitwise operation in C on t.
Integral types
These types are are represented as newtypes of types in Data.Int and Data.Word, and are instances of Eq, Ord, Num, Read, Show, Enum, Typeable, Storable, Bounded, Real, Integral and Bits.
data CChar
Haskell type representing the C char type.
Instances
Read CChar
Show CChar
Typeable CChar
Eq CChar
Ord CChar
Num CChar
Enum CChar
Storable CChar
Real CChar
Bounded CChar
Integral CChar
Bits CChar
data CSChar
Haskell type representing the C signed char type.
Instances
Read CSChar
Show CSChar
Typeable CSChar
Eq CSChar
Ord CSChar
Num CSChar
Enum CSChar
Storable CSChar
Real CSChar
Bounded CSChar
Integral CSChar
Bits CSChar
data CUChar
Haskell type representing the C unsigned char type.
Instances
Read CUChar
Show CUChar
Typeable CUChar
Eq CUChar
Ord CUChar
Num CUChar
Enum CUChar
Storable CUChar
Real CUChar
Bounded CUChar
Integral CUChar
Bits CUChar
data CShort
Haskell type representing the C short type.
Instances
Read CShort
Show CShort
Typeable CShort
Eq CShort
Ord CShort
Num CShort
Enum CShort
Storable CShort
Real CShort
Bounded CShort
Integral CShort
Bits CShort
data CUShort
Haskell type representing the C unsigned short type.
Instances
Read CUShort
Show CUShort
Typeable CUShort
Eq CUShort
Ord CUShort
Num CUShort
Enum CUShort
Storable CUShort
Real CUShort
Bounded CUShort
Integral CUShort
Bits CUShort
data CInt
Haskell type representing the C int type.
Instances
Read CInt
Show CInt
Typeable CInt
Eq CInt
Ord CInt
Num CInt
Enum CInt
Storable CInt
Real CInt
Bounded CInt
Integral CInt
Bits CInt
data CUInt
Haskell type representing the C unsigned int type.
Instances
Read CUInt
Show CUInt
Typeable CUInt
Eq CUInt
Ord CUInt
Num CUInt
Enum CUInt
Storable CUInt
Real CUInt
Bounded CUInt
Integral CUInt
Bits CUInt
data CLong
Haskell type representing the C long type.
Instances
Read CLong
Show CLong
Typeable CLong
Eq CLong
Ord CLong
Num CLong
Enum CLong
Storable CLong
Real CLong
Bounded CLong
Integral CLong
Bits CLong
data CULong
Haskell type representing the C unsigned long type.
Instances
Read CULong
Show CULong
Typeable CULong
Eq CULong
Ord CULong
Num CULong
Enum CULong
Storable CULong
Real CULong
Bounded CULong
Integral CULong
Bits CULong
data CPtrdiff
Haskell type representing the C ptrdiff_t type.
Instances
Read CPtrdiff
Show CPtrdiff
Typeable CPtrdiff
Eq CPtrdiff
Ord CPtrdiff
Num CPtrdiff
Enum CPtrdiff
Storable CPtrdiff
Real CPtrdiff
Bounded CPtrdiff
Integral CPtrdiff
Bits CPtrdiff
data CSize
Haskell type representing the C size_t type.
Instances
Read CSize
Show CSize
Typeable CSize
Eq CSize
Ord CSize
Num CSize
Enum CSize
Storable CSize
Real CSize
Bounded CSize
Integral CSize
Bits CSize
data CWchar
Haskell type representing the C wchar_t type.
Instances
Read CWchar
Show CWchar
Typeable CWchar
Eq CWchar
Ord CWchar
Num CWchar
Enum CWchar
Storable CWchar
Real CWchar
Bounded CWchar
Integral CWchar
Bits CWchar
data CSigAtomic
Haskell type representing the C sig_atomic_t type.
Instances
Read CSigAtomic
Show CSigAtomic
Typeable CSigAtomic
Eq CSigAtomic
Ord CSigAtomic
Num CSigAtomic
Enum CSigAtomic
Storable CSigAtomic
Real CSigAtomic
Bounded CSigAtomic
Integral CSigAtomic
Bits CSigAtomic
data CLLong
Haskell type representing the C long long type.
Instances
Read CLLong
Show CLLong
Typeable CLLong
Eq CLLong
Ord CLLong
Num CLLong
Enum CLLong
Storable CLLong
Real CLLong
Bounded CLLong
Integral CLLong
Bits CLLong
data CULLong
Haskell type representing the C unsigned long long type.
Instances
Read CULLong
Show CULLong
Typeable CULLong
Eq CULLong
Ord CULLong
Num CULLong
Enum CULLong
Storable CULLong
Real CULLong
Bounded CULLong
Integral CULLong
Bits CULLong
data CIntPtr
Instances
Read CIntPtr
Show CIntPtr
Typeable CIntPtr
Eq CIntPtr
Ord CIntPtr
Num CIntPtr
Enum CIntPtr
Storable CIntPtr
Real CIntPtr
Bounded CIntPtr
Integral CIntPtr
Bits CIntPtr
data CUIntPtr
Instances
Read CUIntPtr
Show CUIntPtr
Typeable CUIntPtr
Eq CUIntPtr
Ord CUIntPtr
Num CUIntPtr
Enum CUIntPtr
Storable CUIntPtr
Real CUIntPtr
Bounded CUIntPtr
Integral CUIntPtr
Bits CUIntPtr
data CIntMax
Instances
Read CIntMax
Show CIntMax
Typeable CIntMax
Eq CIntMax
Ord CIntMax
Num CIntMax
Enum CIntMax
Storable CIntMax
Real CIntMax
Bounded CIntMax
Integral CIntMax
Bits CIntMax
data CUIntMax
Instances
Read CUIntMax
Show CUIntMax
Typeable CUIntMax
Eq CUIntMax
Ord CUIntMax
Num CUIntMax
Enum CUIntMax
Storable CUIntMax
Real CUIntMax
Bounded CUIntMax
Integral CUIntMax
Bits CUIntMax
Numeric types
These types are are represented as newtypes of basic foreign types, and are instances of Eq, Ord, Num, Read, Show, Enum, Typeable and Storable.
data CClock
Haskell type representing the C clock_t type.
Instances
Read CClock
Show CClock
Typeable CClock
Eq CClock
Ord CClock
Num CClock
Enum CClock
Storable CClock
Real CClock
data CTime
Haskell type representing the C time_t type.
Instances
Read CTime
Show CTime
Typeable CTime
Eq CTime
Ord CTime
Num CTime
Enum CTime
Storable CTime
Real CTime
Floating types
These types are are represented as newtypes of Float and Double, and are instances of Eq, Ord, Num, Read, Show, Enum, Typeable, Storable, Real, Fractional, Floating, RealFrac and RealFloat.
data CFloat
Haskell type representing the C float type.
Instances
Read CFloat
Show CFloat
Typeable CFloat
Eq CFloat
Ord CFloat
Num CFloat
Enum CFloat
Storable CFloat
Real CFloat
Fractional CFloat
Floating CFloat
RealFrac CFloat
RealFloat CFloat
data CDouble
Haskell type representing the C double type.
Instances
Read CDouble
Show CDouble
Typeable CDouble
Eq CDouble
Ord CDouble
Num CDouble
Enum CDouble
Storable CDouble
Real CDouble
Fractional CDouble
Floating CDouble
RealFrac CDouble
RealFloat CDouble
data CLDouble
Haskell type representing the C long double type.
Instances
Read CLDouble
Show CLDouble
Typeable CLDouble
Eq CLDouble
Ord CLDouble
Num CLDouble
Enum CLDouble
Storable CLDouble
Real CLDouble
Fractional CLDouble
Floating CLDouble
RealFrac CLDouble
RealFloat CLDouble
Other types
data CFile
Haskell type representing the C FILE type.
data CFpos
Haskell type representing the C fpos_t type.
data CJmpBuf
Haskell type representing the C jmp_buf type.
Produced by Haddock version 0.6