haskell / containers

Assorted concrete container types
https://hackage.haskell.org/package/containers
315 stars 178 forks source link

Improve strictness tests #1019

Open meooow25 opened 1 month ago

meooow25 commented 1 month ago

Strictness tests need to be in good shape to avoid bugs like #996

meooow25 commented 1 month ago

Just started and I'm seeing things like

λ> import qualified Data.Map.Strict as M
λ> M.fromList [(1,undefined),(1,2)]
fromList *** Exception: Prelude.undefined
λ> M.fromAscList [(1,undefined),(1,2)]
fromList [(1,2)]

Hope there aren't too many of these...

Edit: To clarify, this is not a bug. Both do not allow bottom into the map. It's just inconsistent.

Edit: Turns out this is a known issue #473

treeowl commented 1 month ago

Uh oh.... I assume that second one extracted to a Set?

meooow25 commented 1 month ago

I'm not sure what you mean. It's just a consequence of the different implementations.

meooow25 commented 1 month ago

Looking around at the tests we have today, we seem to be using two libraries:

We can test strictness by detecting bottoms, but the nothunks machinery seems massively more powerful than what we need. nothunks is intended to find thunks in nested data by exploring it in the manner of NFData. We don't have such nested data in containers, it's just about whether maps contain bottom values or whether strict folds indeed fold strictly. I think we could remove this dependency if we wanted.

We can perhaps even inline the bits of ChasingBottoms we use and remove that too. But I'll leave that for later.