haskellsetcontainersstrictness

Does Haskell have a strict Set container?


If we look at the containers package. They have Data.Map.Strict, but there is no equivalent Data.Set.Strict. Would it make sense for it to exist?


Solution

  • Set is strict. In a same way as both Map.Lazy and Map.Strict are strict in the key. E.g from the Data.Map.Lazy module:

    This module satisfies the following strictness property:

    • Key arguments are evaluated to WHNF

    The reason is quite obvious: to make any decisions (i.e. something else than always return EQ) the compare have to evaluate the arguments to at least a WHNF (to separate different constructors in a sum type, e.g.)