[Haskell-cafe] Ptr Word8 display question
Antoine Latter
aslatter at gmail.com
Sun Jun 29 00:57:32 EDT 2008
2008/6/28 Galchin, Vasili <vigalchin at gmail.com>:
> Hi,
>
> Suppose I have a value of type Ptr Word8 and also an Int which is the
> length of the Ptr Word8(sorry if I am thinking too much in a C string frame
> of mind). How can I display the Ptr Word8 value of the given length?
>
> Vasili
>
You're best bet would be to use 'peekArray' or 'withArrayLen' to get a
list of Word8 values, and then display that however you want.
withArrayLen: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-Marshal-Array.html#v%3AwithArrayLen
peekArray: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-Marshal-Array.html#v%3ApeekArray
I hope that helps!
-Antoine
More information about the Haskell-Cafe
mailing list