[Haskell-cafe] Re: MD5?

Aaron Denney wnoise at ofb.net
Sat Nov 17 15:11:40 EST 2007


On 2007-11-17, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
>   pack8into16 :: [Word8] -> Word16
>   pack8into32 :: [Word8] -> Word32
>   unpack16into8 :: Word16 -> [Word8]
>   unpack32into8 :: Word32 -> [Word8]
>   pack8into16s :: [Word8] -> [Word16]
>   pack8into32s :: [Word8] -> [Word32]
>   etc.
>
> I had to write all these myself, by hand, and then check that I got 
> everything the right way round and so forth. (And every now and then I 
> find an edge case where these functions go wrong.)

Well, you know, some of these are really the wrong signatures:

pack8into16 :: (Word8, Word8) -> Word16
pack8into32 :: (Word8, Word8, Word8, Word8) -> Word32
unpack16into8 :: Word16 -> (Word8, Word8)
unpack32into8 :: Word32 -> (Word8, Word8, Word8, Word8)

curry the above to taste.

-- 
Aaron Denney
-><-



More information about the Haskell-Cafe mailing list