Does Haskell have a strict Set container?
Asked Answered
F

1

8

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?

Freytag answered 27/4, 2017 at 20:52 Comment(0)
H
11

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

Hanan answered 27/4, 2017 at 21:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.