[Haskell-beginners] Bit Manipulation

Yitzchak Gale gale at sefer.org
Fri May 21 08:44:24 EDT 2010

Hi Daniel,

Daniel Rozycki wrote:
> Currently, I am storing the two values each as Word16s, bitshifting one of
> them left by nine (using shift in the Data.Bits module), and then adding the
> two. Is there a simpler and/or more elegant way of achieving this result?

That's about what I would do in C. What's wrong with doing it that
way in Haskell? GHC should be smart enough to do pretty well
with those kinds of combinations.

If you do this sort of thing all the time and there are some combinators
that would make it more convenient for you - go ahead and make a
library out of them. And upload it to Hackage!


More information about the Beginners mailing list