base-4.11.0.0: Basic libraries

Copyright(c) The FFI task force 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerffi@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Foreign.C.Types

Contents

Description

Mapping of C types to corresponding Haskell 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 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.

Platform differences

This module contains platform specific information about types. __/As such the types presented on this page reflect the platform on which the documentation was generated and may not coincide with the types on your platform./__

Integral types

These types 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.

newtype CChar Source #

Haskell type representing the C char type.

Constructors

CChar Int8 
Instances
Bounded CChar Source # 
Instance details
Enum CChar Source # 
Instance details
Eq CChar Source # 
Instance details

Methods

(==) :: CChar -> CChar -> Bool #

(/=) :: CChar -> CChar -> Bool #

Integral CChar Source # 
Instance details
Num CChar Source # 
Instance details
Ord CChar Source # 
Instance details

Methods

compare :: CChar -> CChar -> Ordering #

(<) :: CChar -> CChar -> Bool #

(<=) :: CChar -> CChar -> Bool #

(>) :: CChar -> CChar -> Bool #

(>=) :: CChar -> CChar -> Bool #

max :: CChar -> CChar -> CChar #

min :: CChar -> CChar -> CChar #

Read CChar Source # 
Instance details
Real CChar Source # 
Instance details
Show CChar Source # 
Instance details
FiniteBits CChar Source # 
Instance details
Bits CChar Source # 
Instance details
Storable CChar Source # 
Instance details

newtype CSChar Source #

Haskell type representing the C signed char type.

Constructors

CSChar Int8 
Instances
Bounded CSChar Source # 
Instance details
Enum CSChar Source # 
Instance details
Eq CSChar Source # 
Instance details

Methods

(==) :: CSChar -> CSChar -> Bool #

(/=) :: CSChar -> CSChar -> Bool #

Integral CSChar Source # 
Instance details
Num CSChar Source # 
Instance details
Ord CSChar Source # 
Instance details
Read CSChar Source # 
Instance details
Real CSChar Source # 
Instance details
Show CSChar Source # 
Instance details
FiniteBits CSChar Source # 
Instance details
Bits CSChar Source # 
Instance details
Storable CSChar Source # 
Instance details

newtype CUChar Source #

Haskell type representing the C unsigned char type.

Constructors

CUChar Word8 
Instances
Bounded CUChar Source # 
Instance details
Enum CUChar Source # 
Instance details
Eq CUChar Source # 
Instance details

Methods

(==) :: CUChar -> CUChar -> Bool #

(/=) :: CUChar -> CUChar -> Bool #

Integral CUChar Source # 
Instance details
Num CUChar Source # 
Instance details
Ord CUChar Source # 
Instance details
Read CUChar Source # 
Instance details
Real CUChar Source # 
Instance details
Show CUChar Source # 
Instance details
FiniteBits CUChar Source # 
Instance details
Bits CUChar Source # 
Instance details
Storable CUChar Source # 
Instance details

newtype CShort Source #

Haskell type representing the C short type.

Constructors

CShort Int16 
Instances
Bounded CShort Source # 
Instance details
Enum CShort Source # 
Instance details
Eq CShort Source # 
Instance details

Methods

(==) :: CShort -> CShort -> Bool #

(/=) :: CShort -> CShort -> Bool #

Integral CShort Source # 
Instance details
Num CShort Source # 
Instance details
Ord CShort Source # 
Instance details
Read CShort Source # 
Instance details
Real CShort Source # 
Instance details
Show CShort Source # 
Instance details
FiniteBits CShort Source # 
Instance details
Bits CShort Source # 
Instance details
Storable CShort Source # 
Instance details

newtype CUShort Source #

Haskell type representing the C unsigned short type.

Constructors

CUShort Word16 
Instances
Bounded CUShort Source # 
Instance details
Enum CUShort Source # 
Instance details
Eq CUShort Source # 
Instance details

Methods

(==) :: CUShort -> CUShort -> Bool #

(/=) :: CUShort -> CUShort -> Bool #

Integral CUShort Source # 
Instance details
Num CUShort Source # 
Instance details
Ord CUShort Source # 
Instance details
Read CUShort Source # 
Instance details
Real CUShort Source # 
Instance details
Show CUShort Source # 
Instance details
FiniteBits CUShort Source # 
Instance details
Bits CUShort Source # 
Instance details
Storable CUShort Source # 
Instance details

newtype CInt Source #

Haskell type representing the C int type.

Constructors

CInt Int32 
Instances
Bounded CInt Source # 
Instance details
Enum CInt Source # 
Instance details
Eq CInt Source # 
Instance details

Methods

(==) :: CInt -> CInt -> Bool #

(/=) :: CInt -> CInt -> Bool #

Integral CInt Source # 
Instance details
Num CInt Source # 
Instance details
Ord CInt Source # 
Instance details

Methods

compare :: CInt -> CInt -> Ordering #

(<) :: CInt -> CInt -> Bool #

(<=) :: CInt -> CInt -> Bool #

(>) :: CInt -> CInt -> Bool #

(>=) :: CInt -> CInt -> Bool #

max :: CInt -> CInt -> CInt #

min :: CInt -> CInt -> CInt #

Read CInt Source # 
Instance details
Real CInt Source # 
Instance details
Show CInt Source # 
Instance details
FiniteBits CInt Source # 
Instance details
Bits CInt Source # 
Instance details
Storable CInt Source # 
Instance details

newtype CUInt Source #

Haskell type representing the C unsigned int type.

Constructors

CUInt Word32 
Instances
Bounded CUInt Source # 
Instance details
Enum CUInt Source # 
Instance details
Eq CUInt Source # 
Instance details

Methods

(==) :: CUInt -> CUInt -> Bool #

(/=) :: CUInt -> CUInt -> Bool #

Integral CUInt Source # 
Instance details
Num CUInt Source # 
Instance details
Ord CUInt Source # 
Instance details

Methods

compare :: CUInt -> CUInt -> Ordering #

(<) :: CUInt -> CUInt -> Bool #

(<=) :: CUInt -> CUInt -> Bool #

(>) :: CUInt -> CUInt -> Bool #

(>=) :: CUInt -> CUInt -> Bool #

max :: CUInt -> CUInt -> CUInt #

min :: CUInt -> CUInt -> CUInt #

Read CUInt Source # 
Instance details
Real CUInt Source # 
Instance details
Show CUInt Source # 
Instance details
FiniteBits CUInt Source # 
Instance details
Bits CUInt Source # 
Instance details
Storable CUInt Source # 
Instance details

newtype CLong Source #

Haskell type representing the C long type.

Constructors

CLong Int64 
Instances
Bounded CLong Source # 
Instance details
Enum CLong Source # 
Instance details
Eq CLong Source # 
Instance details

Methods

(==) :: CLong -> CLong -> Bool #

(/=) :: CLong -> CLong -> Bool #

Integral CLong Source # 
Instance details
Num CLong Source # 
Instance details
Ord CLong Source # 
Instance details

Methods

compare :: CLong -> CLong -> Ordering #

(<) :: CLong -> CLong -> Bool #

(<=) :: CLong -> CLong -> Bool #

(>) :: CLong -> CLong -> Bool #

(>=) :: CLong -> CLong -> Bool #

max :: CLong -> CLong -> CLong #

min :: CLong -> CLong -> CLong #

Read CLong Source # 
Instance details
Real CLong Source # 
Instance details
Show CLong Source # 
Instance details
FiniteBits CLong Source # 
Instance details
Bits CLong Source # 
Instance details
Storable CLong Source # 
Instance details

newtype CULong Source #

Haskell type representing the C unsigned long type.

Constructors

CULong Word64 
Instances
Bounded CULong Source # 
Instance details
Enum CULong Source # 
Instance details
Eq CULong Source # 
Instance details

Methods

(==) :: CULong -> CULong -> Bool #

(/=) :: CULong -> CULong -> Bool #

Integral CULong Source # 
Instance details
Num CULong Source # 
Instance details
Ord CULong Source # 
Instance details
Read CULong Source # 
Instance details
Real CULong Source # 
Instance details
Show CULong Source # 
Instance details
FiniteBits CULong Source # 
Instance details
Bits CULong Source # 
Instance details
Storable CULong Source # 
Instance details

newtype CPtrdiff Source #

Haskell type representing the C ptrdiff_t type.

Constructors

CPtrdiff Int64 
Instances
Bounded CPtrdiff Source # 
Instance details
Enum CPtrdiff Source # 
Instance details
Eq CPtrdiff Source # 
Instance details
Integral CPtrdiff Source # 
Instance details
Num CPtrdiff Source # 
Instance details
Ord CPtrdiff Source # 
Instance details
Read CPtrdiff Source # 
Instance details
Real CPtrdiff Source # 
Instance details
Show CPtrdiff Source # 
Instance details
FiniteBits CPtrdiff Source # 
Instance details
Bits CPtrdiff Source # 
Instance details
Storable CPtrdiff Source # 
Instance details

newtype CSize Source #

Haskell type representing the C size_t type.

Constructors

CSize Word64 
Instances
Bounded CSize Source # 
Instance details
Enum CSize Source # 
Instance details
Eq CSize Source # 
Instance details

Methods

(==) :: CSize -> CSize -> Bool #

(/=) :: CSize -> CSize -> Bool #

Integral CSize Source # 
Instance details
Num CSize Source # 
Instance details
Ord CSize Source # 
Instance details

Methods

compare :: CSize -> CSize -> Ordering #

(<) :: CSize -> CSize -> Bool #

(<=) :: CSize -> CSize -> Bool #

(>) :: CSize -> CSize -> Bool #

(>=) :: CSize -> CSize -> Bool #

max :: CSize -> CSize -> CSize #

min :: CSize -> CSize -> CSize #

Read CSize Source # 
Instance details
Real CSize Source # 
Instance details
Show CSize Source # 
Instance details
FiniteBits CSize Source # 
Instance details
Bits CSize Source # 
Instance details
Storable CSize Source # 
Instance details

newtype CWchar Source #

Haskell type representing the C wchar_t type.

Constructors

CWchar Int32 
Instances
Bounded CWchar Source # 
Instance details
Enum CWchar Source # 
Instance details
Eq CWchar Source # 
Instance details

Methods

(==) :: CWchar -> CWchar -> Bool #

(/=) :: CWchar -> CWchar -> Bool #

Integral CWchar Source # 
Instance details
Num CWchar Source # 
Instance details
Ord CWchar Source # 
Instance details
Read CWchar Source # 
Instance details
Real CWchar Source # 
Instance details
Show CWchar Source # 
Instance details
FiniteBits CWchar Source # 
Instance details
Bits CWchar Source # 
Instance details
Storable CWchar Source # 
Instance details

newtype CSigAtomic Source #

Haskell type representing the C sig_atomic_t type.

Constructors

CSigAtomic Int32 
Instances
Bounded CSigAtomic Source # 
Instance details
Enum CSigAtomic Source # 
Instance details
Eq CSigAtomic Source # 
Instance details
Integral CSigAtomic Source # 
Instance details
Num CSigAtomic Source # 
Instance details
Ord CSigAtomic Source # 
Instance details
Read CSigAtomic Source # 
Instance details
Real CSigAtomic Source # 
Instance details
Show CSigAtomic Source # 
Instance details
FiniteBits CSigAtomic Source # 
Instance details
Bits CSigAtomic Source # 
Instance details
Storable CSigAtomic Source # 
Instance details

newtype CLLong Source #

Haskell type representing the C long long type.

Constructors

CLLong Int64 
Instances
Bounded CLLong Source # 
Instance details
Enum CLLong Source # 
Instance details
Eq CLLong Source # 
Instance details

Methods

(==) :: CLLong -> CLLong -> Bool #

(/=) :: CLLong -> CLLong -> Bool #

Integral CLLong Source # 
Instance details
Num CLLong Source # 
Instance details
Ord CLLong Source # 
Instance details
Read CLLong Source # 
Instance details
Real CLLong Source # 
Instance details
Show CLLong Source # 
Instance details
FiniteBits CLLong Source # 
Instance details
Bits CLLong Source # 
Instance details
Storable CLLong Source # 
Instance details

newtype CULLong Source #

Haskell type representing the C unsigned long long type.

Constructors

CULLong Word64 
Instances
Bounded CULLong Source # 
Instance details
Enum CULLong Source # 
Instance details
Eq CULLong Source # 
Instance details

Methods

(==) :: CULLong -> CULLong -> Bool #

(/=) :: CULLong -> CULLong -> Bool #

Integral CULLong Source # 
Instance details
Num CULLong Source # 
Instance details
Ord CULLong Source # 
Instance details
Read CULLong Source # 
Instance details
Real CULLong Source # 
Instance details
Show CULLong Source # 
Instance details
FiniteBits CULLong Source # 
Instance details
Bits CULLong Source # 
Instance details
Storable CULLong Source # 
Instance details

newtype CBool Source #

Haskell type representing the C bool type.

Since: 4.10.0.0

Constructors

CBool Word8 
Instances
Bounded CBool Source # 
Instance details
Enum CBool Source # 
Instance details
Eq CBool Source # 
Instance details

Methods

(==) :: CBool -> CBool -> Bool #

(/=) :: CBool -> CBool -> Bool #

Integral CBool Source # 
Instance details
Num CBool Source # 
Instance details
Ord CBool Source # 
Instance details

Methods

compare :: CBool -> CBool -> Ordering #

(<) :: CBool -> CBool -> Bool #

(<=) :: CBool -> CBool -> Bool #

(>) :: CBool -> CBool -> Bool #

(>=) :: CBool -> CBool -> Bool #

max :: CBool -> CBool -> CBool #

min :: CBool -> CBool -> CBool #

Read CBool Source # 
Instance details
Real CBool Source # 
Instance details
Show CBool Source # 
Instance details
FiniteBits CBool Source # 
Instance details
Bits CBool Source # 
Instance details
Storable CBool Source # 
Instance details

newtype CIntPtr Source #

Constructors

CIntPtr Int64 
Instances
Bounded CIntPtr Source # 
Instance details
Enum CIntPtr Source # 
Instance details
Eq CIntPtr Source # 
Instance details

Methods

(==) :: CIntPtr -> CIntPtr -> Bool #

(/=) :: CIntPtr -> CIntPtr -> Bool #

Integral CIntPtr Source # 
Instance details
Num CIntPtr Source # 
Instance details
Ord CIntPtr Source # 
Instance details
Read CIntPtr Source # 
Instance details
Real CIntPtr Source # 
Instance details
Show CIntPtr Source # 
Instance details
FiniteBits CIntPtr Source # 
Instance details
Bits CIntPtr Source # 
Instance details
Storable CIntPtr Source # 
Instance details

newtype CUIntPtr Source #

Constructors

CUIntPtr Word64 
Instances
Bounded CUIntPtr Source # 
Instance details
Enum CUIntPtr Source # 
Instance details
Eq CUIntPtr Source # 
Instance details
Integral CUIntPtr Source # 
Instance details
Num CUIntPtr Source # 
Instance details
Ord CUIntPtr Source # 
Instance details
Read CUIntPtr Source # 
Instance details
Real CUIntPtr Source # 
Instance details
Show CUIntPtr Source # 
Instance details
FiniteBits CUIntPtr Source # 
Instance details
Bits CUIntPtr Source # 
Instance details
Storable CUIntPtr Source # 
Instance details

newtype CIntMax Source #

Constructors

CIntMax Int64 
Instances
Bounded CIntMax Source # 
Instance details
Enum CIntMax Source # 
Instance details
Eq CIntMax Source # 
Instance details

Methods

(==) :: CIntMax -> CIntMax -> Bool #

(/=) :: CIntMax -> CIntMax -> Bool #

Integral CIntMax Source # 
Instance details
Num CIntMax Source # 
Instance details
Ord CIntMax Source # 
Instance details
Read CIntMax Source # 
Instance details
Real CIntMax Source # 
Instance details
Show CIntMax Source # 
Instance details
FiniteBits CIntMax Source # 
Instance details
Bits CIntMax Source # 
Instance details
Storable CIntMax Source # 
Instance details

newtype CUIntMax Source #

Constructors

CUIntMax Word64 
Instances
Bounded CUIntMax Source # 
Instance details
Enum CUIntMax Source # 
Instance details
Eq CUIntMax Source # 
Instance details
Integral CUIntMax Source # 
Instance details
Num CUIntMax Source # 
Instance details
Ord CUIntMax Source # 
Instance details
Read CUIntMax Source # 
Instance details
Real CUIntMax Source # 
Instance details
Show CUIntMax Source # 
Instance details
FiniteBits CUIntMax Source # 
Instance details
Bits CUIntMax Source # 
Instance details
Storable CUIntMax Source # 
Instance details

Numeric types

These types are represented as newtypes of basic foreign types, and are instances of Eq, Ord, Num, Read, Show, Enum, Typeable and Storable.

newtype CClock Source #

Haskell type representing the C clock_t type.

Constructors

CClock Int64 
Instances
Enum CClock Source # 
Instance details
Eq CClock Source # 
Instance details

Methods

(==) :: CClock -> CClock -> Bool #

(/=) :: CClock -> CClock -> Bool #

Num CClock Source # 
Instance details
Ord CClock Source # 
Instance details
Read CClock Source # 
Instance details
Real CClock Source # 
Instance details
Show CClock Source # 
Instance details
Storable CClock Source # 
Instance details

newtype CTime Source #

Haskell type representing the C time_t type.

Constructors

CTime Int64 
Instances
Enum CTime Source # 
Instance details
Eq CTime Source # 
Instance details

Methods

(==) :: CTime -> CTime -> Bool #

(/=) :: CTime -> CTime -> Bool #

Num CTime Source # 
Instance details
Ord CTime Source # 
Instance details

Methods

compare :: CTime -> CTime -> Ordering #

(<) :: CTime -> CTime -> Bool #

(<=) :: CTime -> CTime -> Bool #

(>) :: CTime -> CTime -> Bool #

(>=) :: CTime -> CTime -> Bool #

max :: CTime -> CTime -> CTime #

min :: CTime -> CTime -> CTime #

Read CTime Source # 
Instance details
Real CTime Source # 
Instance details
Show CTime Source # 
Instance details
Storable CTime Source # 
Instance details

newtype CUSeconds Source #

Haskell type representing the C useconds_t type.

Since: 4.4.0.0

Constructors

CUSeconds Word32 
Instances
Enum CUSeconds Source # 
Instance details
Eq CUSeconds Source # 
Instance details
Num CUSeconds Source # 
Instance details
Ord CUSeconds Source # 
Instance details
Read CUSeconds Source # 
Instance details
Real CUSeconds Source # 
Instance details
Show CUSeconds Source # 
Instance details
Storable CUSeconds Source # 
Instance details

newtype CSUSeconds Source #

Haskell type representing the C suseconds_t type.

Since: 4.4.0.0

Constructors

CSUSeconds Int64 
Instances
Enum CSUSeconds Source # 
Instance details
Eq CSUSeconds Source # 
Instance details
Num CSUSeconds Source # 
Instance details
Ord CSUSeconds Source # 
Instance details
Read CSUSeconds Source # 
Instance details
Real CSUSeconds Source # 
Instance details
Show CSUSeconds Source # 
Instance details
Storable CSUSeconds Source # 
Instance details

To convert CTime to UTCTime, use the following:

\t -> posixSecondsToUTCTime (realToFrac t :: POSIXTime)

Floating types

These types 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.

newtype CFloat Source #

Haskell type representing the C float type.

Constructors

CFloat Float 
Instances
Enum CFloat Source # 
Instance details
Eq CFloat Source # 
Instance details

Methods

(==) :: CFloat -> CFloat -> Bool #

(/=) :: CFloat -> CFloat -> Bool #

Floating CFloat Source # 
Instance details
Fractional CFloat Source # 
Instance details
Num CFloat Source # 
Instance details
Ord CFloat Source # 
Instance details
Read CFloat Source # 
Instance details
Real CFloat Source # 
Instance details
RealFloat CFloat Source # 
Instance details
RealFrac CFloat Source # 
Instance details
Show CFloat Source # 
Instance details
Storable CFloat Source # 
Instance details

newtype CDouble Source #

Haskell type representing the C double type.

Constructors

CDouble Double 
Instances
Enum CDouble Source # 
Instance details
Eq CDouble Source # 
Instance details

Methods

(==) :: CDouble -> CDouble -> Bool #

(/=) :: CDouble -> CDouble -> Bool #

Floating CDouble Source # 
Instance details
Fractional CDouble Source # 
Instance details
Num CDouble Source # 
Instance details
Ord CDouble Source # 
Instance details
Read CDouble Source # 
Instance details
Real CDouble Source # 
Instance details
RealFloat CDouble Source # 
Instance details
RealFrac CDouble Source # 
Instance details
Show CDouble Source # 
Instance details
Storable CDouble Source # 
Instance details

Other types

data CFile Source #

Haskell type representing the C FILE type.

data CFpos Source #

Haskell type representing the C fpos_t type.

data CJmpBuf Source #

Haskell type representing the C jmp_buf type.