Foreign.C.Types (original) (raw)
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 CTrepresenting 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](Foreign-Storable.html#v:sizeOf "Foreign.Storable")` (`[undefined](Prelude.html#v:undefined "Prelude")` :: CT)will yield the same value assizeof (t)in C.`[alignment](Foreign-Storable.html#v:alignment "Foreign.Storable")` (`[undefined](Prelude.html#v:undefined "Prelude")` :: CT)matches the alignment constraint enforced by the C implementation fort.- The members
[peek](Foreign-Storable.html#v:peek "Foreign.Storable")and[poke](Foreign-Storable.html#v:poke "Foreign.Storable")of the[Storable](Foreign-Storable.html#t:Storable "Foreign.Storable")class map all values ofCTto the corresponding value oftand vice versa. - When an instance of
[Bounded](Prelude.html#v:Bounded "Prelude")is defined forCT, the values of[minBound](Prelude.html#v:minBound "Prelude")and[maxBound](Prelude.html#v:maxBound "Prelude")coincide witht_MINandt_MAXin C. - When an instance of
[Eq](Prelude.html#v:Eq "Prelude")or[Ord](Prelude.html#v:Ord "Prelude")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](Prelude.html#v:Num "Prelude"),[Read](Prelude.html#v:Read "Prelude"),[Integral](Prelude.html#v:Integral "Prelude"),[Fractional](Prelude.html#v:Fractional "Prelude"),[Floating](Prelude.html#v:Floating "Prelude"),[RealFrac](Prelude.html#v:RealFrac "Prelude"), or[RealFloat](Prelude.html#v:RealFloat "Prelude")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](GHC-Bits.html#t:Bits "GHC.Bits")is defined forCT, the bitwise operation defined by the type class implement the same function as the corresponding bitwise operation in C ont.
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.
These types are represented as newtypes of types in Data.Int and Data.Word, and are instances of[Eq](Prelude.html#v:Eq "Prelude"), [Ord](Prelude.html#v:Ord "Prelude"), [Num](Prelude.html#v:Num "Prelude"), [Read](Prelude.html#v:Read "Prelude"),[Show](Prelude.html#v:Show "Prelude"), [Enum](Prelude.html#v:Enum "Prelude"), [Typeable](Data-Typeable.html#v:Typeable "Data.Typeable"),[Storable](Foreign-Storable.html#t:Storable "Foreign.Storable"), [Bounded](Prelude.html#v:Bounded "Prelude"), [Real](Prelude.html#v:Real "Prelude"), [Integral](Prelude.html#v:Integral "Prelude") and [Bits](GHC-Bits.html#t:Bits "GHC.Bits").
Haskell type representing the C unsigned char type.(The concrete types of Foreign.C.Types are platform-specific.)
Haskell type representing the C unsigned int type.(The concrete types of Foreign.C.Types are platform-specific.)
Haskell type representing the C unsigned long type.(The concrete types of Foreign.C.Types are platform-specific.)
Haskell type representing the C unsigned long long type.(The concrete types of Foreign.C.Types are platform-specific.)
Haskell type representing the C bool type.(The concrete types of Foreign.C.Types are platform-specific.)
Since: base-4.10.0.0
Haskell type representing the C useconds_t type.(The concrete types of Foreign.C.Types are platform-specific.)
Since: base-4.4.0.0
Haskell type representing the C suseconds_t type.(The concrete types of Foreign.C.Types are platform-specific.)
Since: base-4.4.0.0
To convert [CTime](Foreign-C-Types.html#t:CTime "Foreign.C.Types") to [UTCTime](Data-Time.html#v:UTCTime "Data.Time"), use the following:
\t -> posixSecondsToUTCTime (realToFrac t :: POSIXTime)
These types are represented as newtypes of[Float](Prelude.html#v:Float "Prelude") and [Double](Prelude.html#v:Double "Prelude"), and are instances of[Eq](Prelude.html#v:Eq "Prelude"), [Ord](Prelude.html#v:Ord "Prelude"), [Num](Prelude.html#v:Num "Prelude"), [Read](Prelude.html#v:Read "Prelude"),[Show](Prelude.html#v:Show "Prelude"), [Enum](Prelude.html#v:Enum "Prelude"), [Typeable](Data-Typeable.html#v:Typeable "Data.Typeable"), [Storable](Foreign-Storable.html#t:Storable "Foreign.Storable"),[Real](Prelude.html#v:Real "Prelude"), [Fractional](Prelude.html#v:Fractional "Prelude"), [Floating](Prelude.html#v:Floating "Prelude"),[RealFrac](Prelude.html#v:RealFrac "Prelude") and [RealFloat](Prelude.html#v:RealFloat "Prelude"). That does mean that [CFloat](Foreign-C-Types.html#t:CFloat "Foreign.C.Types")'s (respectively [CDouble](Foreign-C-Types.html#t:CDouble "Foreign.C.Types")'s) instances of[Eq](Prelude.html#v:Eq "Prelude"), [Ord](Prelude.html#v:Ord "Prelude"), [Num](Prelude.html#v:Num "Prelude") and[Fractional](Prelude.html#v:Fractional "Prelude") are as badly behaved as [Float](Prelude.html#v:Float "Prelude")'s (respectively [Double](Prelude.html#v:Double "Prelude")'s).