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

Anthony Cowley acowley at seas.upenn.edu
Mon Sep 29 16:50:33 UTC 2014


> On Sep 29, 2014, at 12:39 PM, Brandon Allbery <allbery.b at gmail.com> wrote:
> 
>> On Mon, Sep 29, 2014 at 12:32 PM, Anthony Cowley <acowley at seas.upenn.edu> 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.

Anthony

> -- 
> brandon s allbery kf8nh                               sine nomine associates
> allbery.b at gmail.com                                  ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140929/fbacfca4/attachment.html>


More information about the Libraries mailing list