On this page
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
tas an argument or result type, the use ofCTin 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 forCThas a valid representation in C. sizeOf (undefined :: CT)will yield the same value assizeof (t)in C.alignment (undefined :: CT)matches the alignment constraint enforced by the C implementation fort.- The members
peekandpokeof theStorableclass map all values ofCTto the corresponding value oftand vice versa. - When an instance of
Boundedis defined forCT, the values ofminBoundandmaxBoundcoincide witht_MINandt_MAXin C. - When an instance of
EqorOrdis 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, orRealFloatis 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
Bitsis defined forCT, the bitwise operation defined by the type class implement the same function as the corresponding bitwise operation in C ont.
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.
Haskell type representing the C char type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C signed char type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C unsigned char type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C short type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C unsigned short type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C int type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C unsigned int type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C long type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C unsigned long type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C ptrdiff_t type. (The concrete types of Foreign.C.Types are platform-specific.)
Instances
Haskell type representing the C size_t type. (The concrete types of Foreign.C.Types are platform-specific.)