What libraries do exist that implement strict data structures? Specifically, I am looking for strict lists and strict sets.
Disclaimers:
-
I am aware of deepseq. It’s very useful, but it adds the overhead of traversing the whole data structure every time you use deepseq (which might be more than once).
-
I am aware that a strict container-like data structure does not
ensure everything it contains will be fully evaluated, but the structure
itself should be strict, e.g.:data StrictList a = !a :$ !(StrictList a) | Empty(Here, the contained elements are in WHNF, and possibly not fully evaluated, but the structure of the list is. For example, infinite lists will be non-terminating values.)
-
I know about the ‘strict’ package on hackage, but it has a very
limited set of strict data structures. It does neither contain strict
lists nor sets. -
Writing strict lists myself seems amazingly easy (I love ghc’s
extensions to derive Functor, Traversable and Foldable, btw.), but it
still seems like it would be better done in a separate library. And
efficient implementations of sets don’t seem that trivial to me.
The
containerspackage (shipped with ghc) will soon have strict Set and Map variants (I’m not sure they will be included with ghc-7.4, but there’s reason to hope). So an efficient implementation of strict Sets and Maps is on the way. Strict lists are, as you say easy, still a package on hackage providing them would be nice, so not everybody has to do it themselves. What else do you need?