I wrote:
I've just commited a change to the fptools repository, proposing a minor change in the FFI spec, see below. Comments welcome. [...]
My previous mail was a little bit terse, so I'd like to explain my proposal in more detail: A part of the FFI spec describes a mapping of some C types to Haskell types (CInt & friends), including the instances defined for them. The relevant C types are (in C99-speak) "integer types" (char, short int, ...), "floating types" (float, double, long double), and "arithmetic types" (= union of integer and floating types). The Haskell instances for the corresponding types should mirror what one can do with the C types. This is almost the case, but my point is that for the arithmetic types CTime and CClock (= clock_t/time_t), Real instances are missing in the spec. Having only Num available, one can convert an Integer (and other Integral types via fromIntegral) to such a type, but not the other way round, although this is perfectly possible in C. Having a Real instance available, too, one could do this, e.g. via: round . fromRational . toRational This would mirror being able to say in C: time_t t = ... int i = (int)t; In a nutshell: I propose to add Real instances to CTime and CClock. Additionally, the wording of the relevant part of the FFI spec should probably use the same terms as C99 (integer/floating/arithmetic types), define the instances for these kind of types, and say e.g. that CTime is an arithmetic type. This would make things a bit clearer and less redundant. Cheers, S.