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

Anthony Cowley acowley at
Mon Sep 29 16:50:33 UTC 2014

> On Sep 29, 2014, at 12:39 PM, Brandon Allbery <allbery.b at> wrote:
>> On Mon, Sep 29, 2014 at 12:32 PM, Anthony Cowley <acowley at> wrote:
>> Part of what distinguishes Bits here is specifically what we're discussing. There is some level of agreement that there should be a non-short-circuiting operation on Bool somewhere, and the proposal points out that such a thing fits into Bits quite well because it is consistent with other Bits instances. It happens that this also suits my intuition about the use of bitwise operations, and that turning to Bits suggests that the programmer is digging a bit deeper into a representation than is perhaps usual. Since different folks have different intuitions, however, I think a vote is the only useful way forward.
> Maybe I should just formally propose
>     newtype Bit = Bit { unBit :: Bool }
> with the appropriate derived instances, and a strict Bits instance. The distinction between Bit and Bool also seems to fit my intuitions.

Yes, the differing opinions make the newtype introduction appealing, but if Bits is eventually made lazier to support generalized short-circuiting, will this then be a wart there? I've really liked a lot of the points I've seen from both sides of this debate, so it'd be great to navigate the branchy vs branchless crossroads with a bit of style.


> -- 
> brandon s allbery kf8nh                               sine nomine associates
> allbery.b at                                  ballbery at
> unix, openafs, kerberos, infrastructure, xmonad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list