On 26 Apr 2011, at 13:31, Eric Stansifer wrote:
>>> Let 'c2h' convert CStrings to Haskell Strings, and 'h2c' convert
>>> Haskell Strings to CStrings. (If I understand correctly, c2h . h2c
>>> === id, but h2c . c2h is not the identity on all inputs;
>>
>> That is correct. CStrings are 8-bits, and Haskell Strings are 32-bits.
>> Converting from Haskell to C loses information, unless you use a multi-byte
>> encoding on the C side (for instance, UTF8).
>
> So actually I am incorrect, and h2c . c2h is the identity but c2h . h2c is
> not?
Ah, my bad. In reading the composition from right to left, I inadvertently
read h2c and c2h from right to left as well! So, starting from C, converting
to Haskell, and back to C is the identity, yes. Starting from Haskell, no.
Regards,
Malcolm
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe