<br><div class="gmail_quote">On Mon, Mar 1, 2010 at 09:40, Leon Smith<span dir="ltr"></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im">On Mon, Mar 1, 2010 at 2:39 AM, Sean Leather wrote:<br>
&gt; It seems more intuitive to reverse the naming. The key parameter to<br>
&gt; lookupFloor is actually the ceiling, and the key returned is the greatest<br>
&gt; key less than or equal to the ceiling. Since there is no floor involved<br>
&gt; here, I would call the function lookupCeiling.<br>
<br>
</div>The greatest number less than something would be the floor.  :-)<br></blockquote><div><br>So, what I didn&#39;t say (but was thinking) was that I would find these renamings more intuitive:<br><br>lookupFloor --&gt; lookupWithCeiling<br>

lookupCeiling --&gt; lookupWithFloor<br><br>These tell me that the key is the ceiling or floor value.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


For example:<br>
<br>
ghci&gt;  let map = Map.fromList [ (x, ()) | x &lt;- [0,10..1000] ]<br>
ghci&gt;  lookupFloor 75 map<br>
   Just (70, ())<br>
ghci&gt;  floor 7.5<br>
   7<br>
ghci&gt;  lookupCeiling 115 map<br>
   Just (120,())<br>
ghci&gt;  ceiling 11.5<br>
   12<br></blockquote><div><br>I understand where you&#39;re coming from. You&#39;re mapping the set of keys to the set of integers and applying the (e.g.) floor function to the key within that set. Alternative (though verbose) names for your functions might be:<br>

<br>lookupFloor --&gt; applyFloorAndLookup<br>
lookupCeiling --&gt; applyCeilingAndLookup<br><br>In contrast, I looked at the parameter as being the lower or upper bound. So, perhaps an even better naming (from my point of view) would be:<br><br>lookupFloor --&gt; lookupWithUpperBound or lookupUpperBound or lookupUB or ...<br>

lookupCeiling --&gt; lookupWithLowerBound or lookupLowerBound or lookupLB or ...<br><br>Something like this might also remove any confusion about floor and ceiling.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


But honestly I almost invariably get the definitions of floor and<br>
ceiling wrong unless I stop to think for a few seconds.   I&#39;ve trained<br>
myself to do that.  ;-)</blockquote><div><br>With your current naming scheme, I think I would constantly choose the opposite function. But maybe that&#39;s just me.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Maybe a few examples in the haddocks would<br>
be in order.   That&#39;s easier to comprehend,  if you know approximately<br>
what it should do.<br></blockquote><div><br>Whatever is the end result, I think you should definitely have some examples in the documentation.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


Also, it occurs to me that maybe a combined function :: (Ord k) =&gt; k<br>
-&gt; Map k v -&gt; (Maybe k v, Maybe k v)  would be useful in addition to<br>
or in place of lookupFloor and lookupCeiling.  But I&#39;m not sure.<br></blockquote></div><br>I don&#39;t know either.<br><br>Regards,<br>Sean<br>