1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
4 -- Module : Foreign.C.TypesISO
5 -- Copyright : (c) The FFI task force 2001
6 -- License : BSD-style (see the file libraries/core/LICENSE)
8 -- Maintainer : ffi@haskell.org
9 -- Stability : provisional
10 -- Portability : portable
12 -- $Id: TypesISO.hs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
14 -- A mapping of C types defined by the ISO C standard to corresponding Haskell
15 -- types. Like CTypes, this is a cool hack...
17 -----------------------------------------------------------------------------
19 module Foreign.C.TypesISO
20 ( -- Integral types, instances of: Eq, Ord, Num, Read, Show, Enum,
21 -- Typeable, Storable, Bounded, Real, Integral, Bits
22 CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..)
24 -- Numeric types, instances of: Eq, Ord, Num, Read, Show, Enum,
26 , CClock(..), CTime(..),
28 , CFile, CFpos, CJmpBuf
31 import Data.Bits ( Bits(..) )
36 #ifdef __GLASGOW_HASKELL__
47 INTEGRAL_TYPE(CPtrdiff,tyConCPtrdiff,"CPtrdiff",HTYPE_PTRDIFF_T)
48 INTEGRAL_TYPE(CSize,tyConCSize,"CSize",HTYPE_SIZE_T)
49 INTEGRAL_TYPE(CWchar,tyConCWchar,"CWchar",HTYPE_WCHAR_T)
50 INTEGRAL_TYPE(CSigAtomic,tyConCSigAtomic,"CSigAtomic",HTYPE_SIG_ATOMIC_T)
53 "fromIntegral/a->CPtrdiff" fromIntegral = \x -> CPtrdiff (fromIntegral x)
54 "fromIntegral/a->CSize" fromIntegral = \x -> CSize (fromIntegral x)
55 "fromIntegral/a->CWchar" fromIntegral = \x -> CWchar (fromIntegral x)
56 "fromIntegral/a->CSigAtomic" fromIntegral = \x -> CSigAtomic (fromIntegral x)
58 "fromIntegral/CPtrdiff->a" fromIntegral = \(CPtrdiff x) -> fromIntegral x
59 "fromIntegral/CSize->a" fromIntegral = \(CSize x) -> fromIntegral x
60 "fromIntegral/CWchar->a" fromIntegral = \(CWchar x) -> fromIntegral x
61 "fromIntegral/CSigAtomic->a" fromIntegral = \(CSigAtomic x) -> fromIntegral x
64 INTEGRAL_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T)
65 INTEGRAL_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T)
67 -- TODO: Instances. But which...? :-}
73 data CJmpBuf = CJmpBuf
75 -- C99 types which are still missing include:
76 -- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t
79 INSTANCE_TYPEABLE0(CPtrdiff,cPtrdiffTc,"CPtrdiff")
80 INSTANCE_TYPEABLE0(CSize,cSizeTc,"CSize")
81 INSTANCE_TYPEABLE0(CWchar,cWcharTc,"CWchar")
82 INSTANCE_TYPEABLE0(CSigAtomic,cSigAtomicTc,"CSigAtomic")
83 INSTANCE_TYPEABLE0(CClock,cClockTc,"CClock")
84 INSTANCE_TYPEABLE0(CTime,cTimeTc,"CTime")