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.