[Haskell-beginners] Word8, Word32, ByteString, Int, etc. conversions.

David McBride dmcbride at neondsl.com
Tue Oct 12 12:38:31 EDT 2010


I'm writing a pcap sniffer, and I have IP addresses from two different
libraries that are equivalent, but typed differently.

Data.IP.IPv4 Data.ByteString.Internal.ByteString

and

Network.Info.IPv4 = Network.Info.IPv4 !GHC.Word.Word32

Both are probably identical, but I cannot for the life of me figure out how
to get from one to the other.  Bytestring has the ability to take arrays of
Word8, how do I split Word32 into Word8's?

I have also had this problem in the past with Word8's, Octets and Chars.
Beyond this specific problem, what is a good strategy for figuring out how
to do these conversions in the future?  Sometimes I find a function
somewhere, but I have never found a general way to deal with it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101012/d0efdf36/attachment.html


More information about the Beginners mailing list