clamp function in base

Sandy Maguire sandy at sandymaguire.me
Fri Sep 11 18:22:04 UTC 2020


My pleasure! Thanks for not letting the experience be a bureaucratic
nightmare!

On Fri, Sep 11, 2020 at 11:19 AM Carter Schonwald <
carter.schonwald at gmail.com> wrote:

> Thanks for helping make this happen!
>
> Should be merged In later today!
>
> On Sat, Aug 15, 2020 at 2:19 PM Sandy Maguire <sandy at sandymaguire.me>
> wrote:
>
>> Sounds good. For whatever reason the tupled arguments make me feel better
>> about the `high<low` having undefined behavior. I'll make the change on the
>> MR.
>>
>> On Sat, Aug 15, 2020 at 8:22 AM Emily Pillmore <emilypi at cohomolo.gy>
>> wrote:
>>
>>> +1, though, David has good points about unnecessary laziness. I'm fine
>>> with the name and the signature
>>>
>>> ```
>>> clamp :: Ord a ⇒ (a,a) → a → a
>>> ```
>>>
>>> (or some variation on the theme).
>>>
>>>
>>> On Fri, Aug 14, 2020 at 5:38 PM, Sandy Maguire <sandy at sandymaguire.me>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> It seems to me that base is missing the very standard function `clamp
>>>> :: Ord a => a -> a -> a -> a`:
>>>>
>>>> ```haskell
>>>> clamp :: Ord a => a -> a -> a -> a
>>>> clamp low high = min high .max low
>>>> ```
>>>>
>>>> I propose it be added to Data.Ord. It's useful, generic, and
>>>> non-trivial to get
>>>>
>>>> right (the "big" number goes with "min" -- causes me cognitive
>>>>
>>>> dissonance every time.)
>>>>
>>>> Thanks,
>>>> Sandy
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>>
>>>>
>>>>
>>>>
>>>> Libraries mailing list
>>>>
>>>>
>>>>
>>>>
>>>> Libraries at haskell.org
>>>>
>>>>
>>>>
>>>>
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>
>>>
>>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> Libraries at haskell.org
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200911/3021c710/attachment.html>


More information about the Libraries mailing list