[Haskell-cafe] Efficient Sets for Small Enumerations

Benjamin Franksen benjamin.franksen at bessy.de
Mon Apr 3 13:31:10 EDT 2006

On Monday 03 April 2006 14:19, David F. Place wrote:
> Often when writing algorithms which involve set operations on small
> enumerations, I start off using Data.Set.  I soon find performance
> requires rewriting that code to use bitwise operations.  I miss the
> nice interface of Data.Set and the type checking of using a proper
> data type.
> So, as an exercise in writing a library, I wrote out an
> implementation of bitwise set operations using the interface of
> Data.Set with a couple of extensions.  It provides an abstract
> interface and type checking.  Using GHC -O3, code compiles right down
> to the primitive bit-twiddling operators.  My example program (a
> sudoku solver) runs several times faster.
> I'll be grateful for any feedback on this.  Perhaps something like it
> would be useful included in the standard libraries.

I wondered about the Ord instance. Wouldn't it be faster to compare 
(word-) representations?


More information about the Haskell-Cafe mailing list