darcs patch: Add proximal lookup functions in Map (and 2 more)

Please see attached 2 patches (and 1 misc patch) to Data.Map which add the ability to lookup entries by proximity. For example, if I have a Map which relates times to the state of a system at that time: let m = Map.fromList [(1, x), (10, y), (15, z)] Then, if I want to find out the state at time 5: Map.nearestLesserOrEqual 5 m -> (1, x) In a similar fashion, nearestGreaterOrEqual and nearest are also provided. Thanks AGL Tue May 22 10:15:05 PDT 2007 agl@imperialviolet.org * Add proximal lookup functions in Map These functions require the key to be an instance of Num, because they use the numerical distance, |x-y|, to find elements in a map which are close to a query key. This is useful, for example, if the map is mapping times to state changes and you want to find out the state at any given time. Tue May 22 10:16:00 PDT 2007 agl@imperialviolet.org * Update deprecated Debug.QuickCheck name Tue May 22 10:16:28 PDT 2007 agl@imperialviolet.org * Add tests for proximal lookup functions -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org 650-283-9641

On Tue, May 22, 2007 at 10:28:24AM -0700, Adam Langley wrote:
Please see attached 2 patches (and 1 misc patch) to Data.Map which add the ability to lookup entries by proximity. For example, if I have a Map which relates times to the state of a system at that time: let m = Map.fromList [(1, x), (10, y), (15, z)] Then, if I want to find out the state at time 5: Map.nearestLesserOrEqual 5 m -> (1, x)
In a similar fashion, nearestGreaterOrEqual and nearest are also provided.
nearest needs Num, but the other two shouldn't.

On 5/22/07, Ross Paterson
nearest needs Num, but the other two shouldn't.
That's a great point, I hadn't thought about that. I don't know if people usually send a correction patch, or remake the patch but I've done the former: Tue May 22 13:41:29 PDT 2007 agl@imperialviolet.org * Num k isn't needed for nearestGreaterOrEqual nor nearestLesserOrEqual -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org 650-283-9641

On 5/22/07, Adam Langley
On 5/22/07, Ross Paterson
wrote: nearest needs Num, but the other two shouldn't.
That's a great point, I hadn't thought about that. I don't know if people usually send a correction patch, or remake the patch but I've done the former:
I can't speak for the protocol of this libraries list, but in darcs-devel people usually use 'amend-record' when the changes are small (like correcting a typo). Jason

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jason Dagit wrote:
On 5/22/07, Adam Langley
wrote: On 5/22/07, Ross Paterson
wrote: nearest needs Num, but the other two shouldn't.
That's a great point, I hadn't thought about that. I don't know if people usually send a correction patch, or remake the patch but I've done the former:
I can't speak for the protocol of this libraries list, but in darcs-devel people usually use 'amend-record' when the changes are small (like correcting a typo).
I prefer making another patch and sending the two patches together, as per the darcs manual http://www.darcs.net/manual/node7.html#SECTION00791000000000000000 in case someone else has already applied the first patch, it makes darcs work better. (the changelog-spamming effect is unfortunate, maybe there should be some convention to distinguish how important a change is, like wikipedia's minor edits? "MINOR: blah blah"... but I don't like that judgement call. Does anyone mind the extra patch-count much?) Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGU2yzHgcxvIWYTTURApCaAKC8qNom2LZLgWG2qJiLZfLDner86wCgglfN XZQCVnTO+bxleUBA48prj1Q= =pBt0 -----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 (cc'ing darcs-users as this is really a darcs issue) Isaac Dupree wrote:
Jason Dagit wrote:
On 5/22/07, Adam Langley
wrote: nearest needs Num, but the other two shouldn't. That's a great point, I hadn't thought about that. I don't know if
On 5/22/07, Ross Paterson
wrote: people usually send a correction patch, or remake the patch but I've done the former: I can't speak for the protocol of this libraries list, but in darcs-devel people usually use 'amend-record' when the changes are small (like correcting a typo). I prefer making another patch and sending the two patches together, as per the darcs manual http://www.darcs.net/manual/node7.html#SECTION00791000000000000000 in case someone else has already applied the first patch, it makes darcs work better. (the changelog-spamming effect is unfortunate
hmm, would it make any sense for an amended patch to list the identities/hashes of the patches that are obsoleted by it, so that this effect isn't such a problem? (Then there would be a functional reason to use amend-record, so I could complain that there doesn't seem to be a way to remove modifications from a patch using amend-record, just to add them) Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWLDLHgcxvIWYTTURArouAKC7jDqiNzL6/K2rvphiA6AiFnEf6wCg1J0+ F86+1fkAxTinzsHBlpNm0TE= =GH0o -----END PGP SIGNATURE-----

On 5/22/07, Adam Langley
That's a great point, I hadn't thought about that. I don't know if people usually send a correction patch, or remake the patch but I've done the former:
Well, I don't think we had a clear resolution on the patch protocol, so this is just a note to say that I think these four patches are ready to be merged if someone with the power considers the extra functions to be worth the extra code. thanks AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org 650-283-9641

"Adam Langley"
That's a great point, I hadn't thought about that. I don't know if people usually send a correction patch, or remake the patch but I've done the former:
In general, the rule would be that a patch published only by email can be amended at low cost, since very few people apply such patches directly to their own repositories. Once a patch has been committed to the main on-line repository however, a large number of people are likely to have pulled it, so amending is no longer suitable, and recording a second patch is preferable. Regards, Malcolm
participants (5)
-
Adam Langley
-
Isaac Dupree
-
Jason Dagit
-
Malcolm Wallace
-
Ross Paterson