Combining Bag/OrdList?

Kavon Farvardin kavon at
Sat Jun 2 16:00:29 UTC 2018

If we have an algorithm that only needs a Bag, then we are free to improve the implementation of Bag in the future so that it doesn’t preserve order under the hood (e.g, use a hash table). So, I personally think it’s useful to have around.

Sent from my phone.

> On Jun 2, 2018, at 5:13 AM, Andreas Klebinger <klebinger.andreas at> wrote:
> We have OrdList which does:
> Provide trees (of instructions), so that lists of instructions
> can be appended in linear time.
> And Bag which claims to be:
> an unordered collection with duplicates
> However the actual implementation of Bag is also a tree if things.
> Given that we have snocBag, consBag that implies to me it's
> also an ordered collection.
> I wondered if besides of someone having to do it if there is a reason why these couldn't be combined
> into a single data structure? Their implementation seems similar enough as far as I can tell.
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at

More information about the ghc-devs mailing list