Proposal: change the Bits instance for Bool to align with other basic types and support branchless calculations

Anthony Cowley acowley at seas.upenn.edu
Sun Sep 28 17:35:18 UTC 2014


> On Sep 28, 2014, at 1:15 PM, David Feuer <david.feuer at gmail.com> wrote:
> 
> 10% sounds pretty big to me when you're trying to really squeeze out a bit more performance (which is what tends to lead people to even look at Data.Bits). The asymptotic hit, as you call it, will only hit you if you use what I consider to be the wrong operator. Why would you use .&. and .|. if what you want are && and ||? From the perspective of the Bits concept, Bool is a bitvector that happens to hold only one bit. Why would you expect that to short-circuit? Why would you use it for control flow?

This is exactly my thinking, too. I'm +1 for consistency, potential speed in ostensibly straight-line code, and offering the opportunity specifically for this distinct behavior.

Anthony



More information about the Libraries mailing list