Containers depending on ghc-prim
Milan Straka
fox at ucw.cz
Wed Oct 12 14:41:20 CEST 2011
Hi all,
is it OK for containers to depend on ghc-prim package? The GHC
documentation says not to use it, but it seems to me people are using it
whenever they need :) I do not know whether there is any policy about
that. Any comments, GHC HQ?
The reason for that is unchecked bit shift. Data.Bits.shift[L|R] and
GHC.Exts.shift[L|RL]# perform checks to ensure the shift is not by more
than WORD_SIZE_IN_BITS. That does not sound like a big deal, but it
causes unnecessary heap allocation that I could not reliably avoid.
Using GHC.Prim.uncheckedShift[L|RL]# produces best code.
Cheers,
Milan
PS: Dependency would be GHC-specific, non-GHC compilers use Data.Bits.shift[L|R].
More information about the Libraries
mailing list