haskell-unordered-containers / unordered-containers

Efficient hashing-based container types
BSD 3-Clause "New" or "Revised" License
221 stars 99 forks source link

More abstractions for low-level code patterns #426

Open sjakobi opened 2 years ago

sjakobi commented 2 years ago

The main advantage of having proper functions for these code patterns is that the functions can have proper documentation.

sjakobi commented 2 years ago

I'm becoming less convinced that introducing anyMatch b1 b2 = b1 .&. b2 /= 0 would be a good idea. It would probably involve re-ordering branches, e.g. where currently b .&. m == 0 comes first.

I also suspect that the pattern is sufficiently simple that additional documentation isn't too important.

sjakobi commented 2 years ago

clearLowestSetBit x = x .&. (x - 1) might be a useful addition.