Combining Bag/OrdList?

Simon Peyton Jones simonpj at microsoft.com
Mon Jun 4 08:29:30 UTC 2018


|  > Imo we lost that ability by exposing consBag & snocBag which imply
|  > that there is a front and a back.

Excellent point!   I agree with Ben here.

* We should rename consBag/snocBag to extendBag
* And use OrdList instead of Bag in any places where the order matters.

Figuring out which those places are would require a little study.

Simon

|  -----Original Message-----
|  From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Ben Gamari
|  Sent: 02 June 2018 18:39
|  To: Andreas Klebinger <klebinger.andreas at gmx.at>; Kavon Farvardin
|  <kavon at farvard.in>
|  Cc: ghc-devs at haskell.org
|  Subject: Re: Combining Bag/OrdList?
|  
|  Andreas Klebinger <klebinger.andreas at gmx.at> writes:
|  
|  >  > we are free to improve the implementation of Bag in the future so
|  > that it doesn’t preserve order
|  >
|  > Imo we lost that ability by exposing consBag & snocBag which imply
|  > that there is a front and a back.
|  > Which at first glance also seem to be already used in GHC with that
|  > behavior in mind.
|  >
|  It looks to me like many of the applications of snocBag should really
|  be using OrdList.
|  
|  In my opinion we should keep the two types apart and simply be more
|  careful about when we use each. There is value in being precise about
|  whether or not ordering of a structure is relevant, even if we don't
|  take advantage of this in the structure's representation.
|  
|  Cheers,
|  
|  - Ben


More information about the ghc-devs mailing list