Skip to content

Clarify the difference between `Bag` and `OrdList`, or merge them

GHC has datatypes Bag and OrdList. What is the difference between them? Why might I choose one over the other? The modules defining them don't seem to give an answer.

My real question: I need a datatype to store a collection of items. Concatenation must be quick. Order does not matter. The only use of the collection will be to iterate through it, which will happen once (and then the collection is discarded). What structure should I use? And, how best should I make this decision?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information