[Haskell-cafe] compilation succeeds -- execution fails

Jonathan Cast jonathanccast at fastmail.fm
Sun Mar 30 14:18:59 EDT 2008

On 29 Mar 2008, at 10:21 PM, Jason Dusek wrote:
> Stefan O'Rear <stefanor at cox.net> wrote:
>>  The only type that you are allowed to assume corresponds to a C  
>> int is
>>  CInt, in the Foreign.C.Types module.  This probably isn't the  
>> problem,
>>  but it could make problems of its own on a 64-bit or otherwise weird
>>  system.
>   So say I turn everything back to pointers to CInt, what is the
>   accepted way to convert from CInt to Int

Use fromIntegral to go CInt -> Int, Int -> CInt.  This only depends  
on CInt being an Integral type.

> and CInt to Char?

Use toEnum . fromIntegral


More information about the Haskell-Cafe mailing list