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

Carter Schonwald carter.schonwald at gmail.com
Mon Sep 29 00:13:39 UTC 2014


I'd actually consider that "spine lazy" definition
instance Bits x => Bits [x] where
  xs .&. ys = zipWith (.&.) xs ys
  xs .|. ya = zipWith (.|.) xs ys


to be the proper "short circuiting" definition, because it has the minimal
work complexity and just a nice lifted version of the pointwise boolean /
bitwise operation.  the "is this all True/1s" lifted version doesnt seem to
provide a good work complexity bound (seems all or nothing).

Otoh, my stance might be a bit heretical or subtley wrong :), NB that I do
undersand that unlike the "batch" short circuit, this one would fail if the
right hand side was "undefined / error", but thats ok :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140928/4ed84b1d/attachment.html>


More information about the Libraries mailing list