Library proposal: add a Location interface for element-wise?operations on Data.Map (#4887)

Heinrich Apfelmus apfelmus at quantentunnel.de
Tue Jan 11 17:35:10 CET 2011


Chung-chieh Shan wrote:
> Ross Paterson <ross at soi.city.ac.uk> wrote:
>>   http://code.haskell.org/~ross/containers_doc/Data-Map.html#3
> 
> Great!
> 
> Given that no function takes two Locations at once, a Location can
> be thought of (and implemented) as a record whose fields are "key",
> "before", "after", etc.  To support this thought, it would be nice if
> all functions that take a Location as argument take it as the first
> argument.  That seems already the case except in "assign".

Since the  Location  comes with invariants (the keys in  before  must be 
smaller than the keys in  after ), the user may not construct it with 
record syntax, so it doesn't really matter whether one of the exported 
functions is composed with  flip .


However, implementing it as a record could be one way to make it faster, 
if GHC were to implement some kind of absence analysis. Namely, the idea 
is that the records fields are independent of each other and usually not 
used all at once. If GHC could detect this, for instance by using 
strictness analysis, then only a specialized/fused version of the  Path 
  needs to be built.


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




More information about the Libraries mailing list