How about extract those bytes directly? Like this:
encodeWord16 x = [ x .&. 0xFF, (x .&. 0xFF00) `shiftR` 8 ]
If you want the signature of encodeWord16
be Word16 -> [Word8]
, then add map fromIntegral
before it, like this:
encodeWord16 :: Word16 -> [Word8]
encodeWord16 x = map fromIntegral [ x .&. 0xFF, (x .&. 0xFF00) `shiftR` 8 ]