haskell / 9 / libraries / base-4.17.0.0 / foreign-c-types.html

Foreign.C.Types

Copyright (c) The FFI task force 2001
License BSD-style (see the file libraries/base/LICENSE)
Maintainer ffi@haskell.org
Stability provisional
Portability portable
Safe Haskell Trustworthy
Language Haskell2010

Description

Mapping of C types to corresponding Haskell types.

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. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CChar Source
Instance details

Defined in Foreign.C.Types

Bits CChar Source
Instance details

Defined in Foreign.C.Types

FiniteBits CChar Source
Instance details

Defined in Foreign.C.Types

Bounded CChar Source
Instance details

Defined in Foreign.C.Types

Enum CChar Source
Instance details

Defined in Foreign.C.Types

Ix CChar Source
Instance details

Defined in Foreign.C.Types

Num CChar Source
Instance details

Defined in Foreign.C.Types

Read CChar Source
Instance details

Defined in Foreign.C.Types

Integral CChar Source
Instance details

Defined in Foreign.C.Types

Real CChar Source
Instance details

Defined in Foreign.C.Types

Show CChar Source
Instance details

Defined in Foreign.C.Types

Eq CChar Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CChar Source
Instance details

Defined in Foreign.C.Types

newtype CSChar Source

Haskell type representing the C signed char type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CSChar Source
Instance details

Defined in Foreign.C.Types

Bits CSChar Source
Instance details

Defined in Foreign.C.Types

FiniteBits CSChar Source
Instance details

Defined in Foreign.C.Types

Bounded CSChar Source
Instance details

Defined in Foreign.C.Types

Enum CSChar Source
Instance details

Defined in Foreign.C.Types

Ix CSChar Source
Instance details

Defined in Foreign.C.Types

Num CSChar Source
Instance details

Defined in Foreign.C.Types

Read CSChar Source
Instance details

Defined in Foreign.C.Types

Integral CSChar Source
Instance details

Defined in Foreign.C.Types

Real CSChar Source
Instance details

Defined in Foreign.C.Types

Show CSChar Source
Instance details

Defined in Foreign.C.Types

Eq CSChar Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CSChar Source
Instance details

Defined in Foreign.C.Types

newtype CUChar Source

Haskell type representing the C unsigned char type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CUChar Source
Instance details

Defined in Foreign.C.Types

Bits CUChar Source
Instance details

Defined in Foreign.C.Types

FiniteBits CUChar Source
Instance details

Defined in Foreign.C.Types

Bounded CUChar Source
Instance details

Defined in Foreign.C.Types

Enum CUChar Source
Instance details

Defined in Foreign.C.Types

Ix CUChar Source
Instance details

Defined in Foreign.C.Types

Num CUChar Source
Instance details

Defined in Foreign.C.Types

Read CUChar Source
Instance details

Defined in Foreign.C.Types

Integral CUChar Source
Instance details

Defined in Foreign.C.Types

Real CUChar Source
Instance details

Defined in Foreign.C.Types

Show CUChar Source
Instance details

Defined in Foreign.C.Types

Eq CUChar Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CUChar Source
Instance details

Defined in Foreign.C.Types

newtype CShort Source

Haskell type representing the C short type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CShort Source
Instance details

Defined in Foreign.C.Types

Bits CShort Source
Instance details

Defined in Foreign.C.Types

FiniteBits CShort Source
Instance details

Defined in Foreign.C.Types

Bounded CShort Source
Instance details

Defined in Foreign.C.Types

Enum CShort Source
Instance details

Defined in Foreign.C.Types

Ix CShort Source
Instance details

Defined in Foreign.C.Types

Num CShort Source
Instance details

Defined in Foreign.C.Types

Read CShort Source
Instance details

Defined in Foreign.C.Types

Integral CShort Source
Instance details

Defined in Foreign.C.Types

Real CShort Source
Instance details

Defined in Foreign.C.Types

Show CShort Source
Instance details

Defined in Foreign.C.Types

Eq CShort Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CShort Source
Instance details

Defined in Foreign.C.Types

newtype CUShort Source

Haskell type representing the C unsigned short type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CUShort Source
Instance details

Defined in Foreign.C.Types

Bits CUShort Source
Instance details

Defined in Foreign.C.Types

FiniteBits CUShort Source
Instance details

Defined in Foreign.C.Types

Bounded CUShort Source
Instance details

Defined in Foreign.C.Types

Enum CUShort Source
Instance details

Defined in Foreign.C.Types

Ix CUShort Source
Instance details

Defined in Foreign.C.Types

Num CUShort Source
Instance details

Defined in Foreign.C.Types

Read CUShort Source
Instance details

Defined in Foreign.C.Types

Integral CUShort Source
Instance details

Defined in Foreign.C.Types

Real CUShort Source
Instance details

Defined in Foreign.C.Types

Show CUShort Source
Instance details

Defined in Foreign.C.Types

Eq CUShort Source
Instance details

Defined in Foreign.C.Types

Ord CUShort Source
Instance details

Defined in Foreign.C.Types

newtype CInt Source

Haskell type representing the C int type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CInt Source
Instance details

Defined in Foreign.C.Types

Bits CInt Source
Instance details

Defined in Foreign.C.Types

FiniteBits CInt Source
Instance details

Defined in Foreign.C.Types

Bounded CInt Source
Instance details

Defined in Foreign.C.Types

Enum CInt Source
Instance details

Defined in Foreign.C.Types

Ix CInt Source
Instance details

Defined in Foreign.C.Types

Num CInt Source
Instance details

Defined in Foreign.C.Types

Read CInt Source
Instance details

Defined in Foreign.C.Types

Integral CInt Source
Instance details

Defined in Foreign.C.Types

Real CInt Source
Instance details

Defined in Foreign.C.Types

Methods

toRational :: CInt -> Rational Source

Show CInt Source
Instance details

Defined in Foreign.C.Types

Eq CInt Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CInt Source
Instance details

Defined in Foreign.C.Types

Methods

compare :: CInt -> CInt -> Ordering Source

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

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

(>) :: CInt -> CInt -> Bool Source

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

max :: CInt -> CInt -> CInt Source

min :: CInt -> CInt -> CInt Source

newtype CUInt Source

Haskell type representing the C unsigned int type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CUInt Source
Instance details

Defined in Foreign.C.Types

Bits CUInt Source
Instance details

Defined in Foreign.C.Types

FiniteBits CUInt Source
Instance details

Defined in Foreign.C.Types

Bounded CUInt Source
Instance details

Defined in Foreign.C.Types

Enum CUInt Source
Instance details

Defined in Foreign.C.Types

Ix CUInt Source
Instance details

Defined in Foreign.C.Types

Num CUInt Source
Instance details

Defined in Foreign.C.Types

Read CUInt Source
Instance details

Defined in Foreign.C.Types

Integral CUInt Source
Instance details

Defined in Foreign.C.Types

Real CUInt Source
Instance details

Defined in Foreign.C.Types

Show CUInt Source
Instance details

Defined in Foreign.C.Types

Eq CUInt Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CUInt Source
Instance details

Defined in Foreign.C.Types

newtype CLong Source

Haskell type representing the C long type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CLong Source
Instance details

Defined in Foreign.C.Types

Bits CLong Source
Instance details

Defined in Foreign.C.Types

FiniteBits CLong Source
Instance details

Defined in Foreign.C.Types

Bounded CLong Source
Instance details

Defined in Foreign.C.Types

Enum CLong Source
Instance details

Defined in Foreign.C.Types

Ix CLong Source
Instance details

Defined in Foreign.C.Types

Num CLong Source
Instance details

Defined in Foreign.C.Types

Read CLong Source
Instance details

Defined in Foreign.C.Types

Integral CLong Source
Instance details

Defined in Foreign.C.Types

Real CLong Source
Instance details

Defined in Foreign.C.Types

Show CLong Source
Instance details

Defined in Foreign.C.Types

Eq CLong Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CLong Source
Instance details

Defined in Foreign.C.Types

newtype CULong Source

Haskell type representing the C unsigned long type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CULong Source
Instance details

Defined in Foreign.C.Types

Bits CULong Source
Instance details

Defined in Foreign.C.Types

FiniteBits CULong Source
Instance details

Defined in Foreign.C.Types

Bounded CULong Source
Instance details

Defined in Foreign.C.Types

Enum CULong Source
Instance details

Defined in Foreign.C.Types

Ix CULong Source
Instance details

Defined in Foreign.C.Types

Num CULong Source
Instance details

Defined in Foreign.C.Types

Read CULong Source
Instance details

Defined in Foreign.C.Types

Integral CULong Source
Instance details

Defined in Foreign.C.Types

Real CULong Source
Instance details

Defined in Foreign.C.Types

Show CULong Source
Instance details

Defined in Foreign.C.Types

Eq CULong Source
Instance details

Defined in Foreign.C.Types

Methods

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

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

Ord CULong Source
Instance details

Defined in Foreign.C.Types

newtype CPtrdiff Source

Haskell type representing the C ptrdiff_t type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Bits CPtrdiff Source
Instance details

Defined in Foreign.C.Types

FiniteBits CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Bounded CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Enum CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Ix CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Num CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Read CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Integral CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Real CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Show CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Eq CPtrdiff Source
Instance details

Defined in Foreign.C.Types

Ord CPtrdiff Source
Instance details

Defined in Foreign.C.Types

newtype CSize Source

Haskell type representing the C size_t type. (The concrete types of Foreign.C.Types are platform-specific.)

Constructors

Instances
Instances details
Storable CSize Source
Instance details

Defined in Foreign.C.Types

Bits CSize Source
Instance details

Defined in Foreign.C.Types

FiniteBits CSize Source
Instance details

Defined in Foreign.C.Types

Bounded CSize Source
Instance details

Defined in Foreign.C.Types

Enum CSize Source
Instance details

Defined in Foreign.C.Types

Ix CSize Source
Instance details

Defined in Foreign.C.Types

Num CSize Source
Instance details

Defined in Foreign.C.Types

Read CSize Source
Instance details

Defined in Foreign.C.Types

Integral CSize Source
Instance details

Defined in Foreign.C.Types

Methods

quot :: CSize -> CSize -> CSize Source

rem :: CSize -> CSize -> CSize Source

div :: CSize -> CSize -> CSize Source

mod :: CSize -> CSize -> CSize Source

quotRem :: CSize ->