[Haskell-cafe] Endian conversion

Joel Reymont joelr1 at gmail.com
Fri Oct 7 10:51:16 EDT 2005


It seems that (BigEndian x) <- peek ptr_x is the culprit.

On Oct 7, 2005, at 4:48 PM, Joel Reymont wrote:

> This code hangs for me for whatever reason when I run it at the  
> ghci prompt. It does not matter whether I load it from a file or  
> type it in.
>
> On Oct 7, 2005, at 2:50 PM, Benjamin Franksen wrote:
>
>
>> You would probably want to wrap/unwrap values (using
>> BigEndian/LittleEndian) just before/after calling poke/peek, like  
>> this:
>>
>> \begin{code}
>> main = do
>>     ptr_x <- new (BigEndian(1::Int))
>>     (BigEndian x) <- peek ptr_x
>>     poke ptr_x (BigEndian 2)
>>     -- poke ptr_x (LittleEndian 3)
>> \end{code}
>>

--
http://wagerlabs.com/idealab







More information about the Haskell-Cafe mailing list