Ticket #7801: ctime_integral.patch

File ctime_integral.patch, 2.0 KB (added by jeffshaw, 2 years ago)

Implements the proposed change.

  • Foreign/C/Types.hs

    From 29d87a1e5eb59df0449d9a313de1f7cfee150f50 Mon Sep 17 00:00:00 2001
    From: Jeff Shaw <[email protected]>
    Date: Fri, 29 Mar 2013 17:33:33 -0400
    Subject: [PATCH] Change C arithmetic types to be integral types.
    
    ---
     Foreign/C/Types.hs | 20 ++++++++++++++++----
     1 file changed, 16 insertions(+), 4 deletions(-)
    
    diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs
    index 234b4ed..2a7e7e7 100644
    a b INTEGRAL_TYPE(CSigAtomic,tyConCSigAtomic,"CSigAtomic",HTYPE_SIG_ATOMIC_T) 
    201201 #-}
    202202
    203203-- | Haskell type representing the C @clock_t@ type.
    204 ARITHMETIC_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T)
     204INTEGRAL_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T)
    205205-- | Haskell type representing the C @time_t@ type.
    206 ARITHMETIC_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T)
     206INTEGRAL_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T)
    207207-- | Haskell type representing the C @useconds_t@ type.
    208 ARITHMETIC_TYPE(CUSeconds,tyConCUSeconds,"CUSeconds",HTYPE_USECONDS_T)
     208INTEGRAL_TYPE(CUSeconds,tyConCUSeconds,"CUSeconds",HTYPE_USECONDS_T)
    209209-- | Haskell type representing the C @suseconds_t@ type.
    210 ARITHMETIC_TYPE(CSUSeconds,tyConCSUSeconds,"CSUSeconds",HTYPE_SUSECONDS_T)
     210INTEGRAL_TYPE(CSUSeconds,tyConCSUSeconds,"CSUSeconds",HTYPE_SUSECONDS_T)
     211
     212{-# RULES
     213"fromIntegral/a->CClock"     fromIntegral = \x -> CClock     (fromIntegral x)
     214"fromIntegral/a->CTime"      fromIntegral = \x -> CClock     (fromIntegral x)
     215"fromIntegral/a->CUSeconds"  fromIntegral = \x -> CUSeconds  (fromIntegral x)
     216"fromIntegral/a->CSUSeconds" fromIntegral = \x -> CSUSeconds (fromIntegral x)
     217
     218"fromIntegral/CClock->a"     fromIntegral = \(CClock     x) -> fromIntegral x
     219"fromIntegral/CTime->a"      fromIntegral = \(CTime      x) -> fromIntegral x
     220"fromIntegral/CUSeconds->a"  fromIntegral = \(CUSeconds  x) -> fromIntegral x
     221"fromIntegral/CSUSeconds->a" fromIntegral = \(CSUSeconds x) -> fromIntegral x
     222 #-}
    211223
    212224-- FIXME: Implement and provide instances for Eq and Storable
    213225-- | Haskell type representing the C @FILE@ type.