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

David Feuer david.feuer at
Mon Sep 29 18:01:45 UTC 2014

I don't think this newtype idea is likely to work out so beautifully.
The main problem is that real code is likely to do a lot of mixing and
matching of short-circuit and non-short-circuit code. The newtype
concept requires a lot of wrapping and unwrapping to express that, and
trying out different approaches to find the fastest leads to a lot of
complicated wrapper rearrangement.

On Mon, Sep 29, 2014 at 12:54 PM, Brandon Allbery <allbery.b at> wrote:
> On Mon, Sep 29, 2014 at 12:50 PM, Anthony Cowley <acowley at>
> wrote:
>> 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.
> I think the point is that this exactly addresses that: people who want the
> spine strictness of the existing Bits instances get it for Bool via the
> newtype and corresponding strict Bits instance (and maybe other instances),
> people who want laziness get it via Bool --- and this also advances the
> cause of generalizing existing Bool-related things, since the next obvious
> thing to do is make it possible to use && and || on a typeclass instead of
> hardcoded for Bool, so they can be extended to Bit.
> --
> brandon s allbery kf8nh                               sine nomine associates
> allbery.b at                                  ballbery at
> unix, openafs, kerberos, infrastructure, xmonad
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list