Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 664
Tarrasch Avatar asked Apr 27 '17 20:04

Tarrasch


1 Answers

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.)

like image 96
phadej Avatar answered Oct 15 '22 07:10

phadej