# Deprecate Foldable for Either

amindfv at gmail.com amindfv at gmail.com
Mon Mar 20 03:48:14 UTC 2017

Tony: I'll take you at your word that you really would like an example of why we have a bee in our bonnet, in order to understand better. Here's an example of a program that can cause pain:

avg l = sum l / fromIntegral (length l)

... elsewhere ...

f x = map (+1) x

...elsewhere...

y = avg \$ f foo

Then we change the definition of f to contain some extra data:

f x = (map (+1) x, bar)

Without warning, we suddenly get "bar" instead of the average we expected, and it all typechecks. Just, the data we get is wrong. We may not even notice the data is wrong at first. This isn't hypothetical: I've been bitten by this more than once. Now I've started writing "(length::[a]->Int)", "(maximum::Ord a=>[a]->a)" etc so I don't shoot myself in the foot.

Tom

> El 19 mar 2017, a las 21:30, Tony Morris <tonymorris at gmail.com> escribiÃ³:
>
> What intuition exactly? Demonstrate it to me so that I may empathise with it. What pain? Show it to me. Are you sure it's intuition and not something else? How are you so sure?
>
>> On Mon, Mar 20, 2017 at 12:28 PM, Artyom Kazak <yom at artyom.me> wrote:
>> On 20 Mar 2017 1:31 a.m., "Tony Morris" <tonymorris at gmail.com> wrote:
>> "But the inconsistency with my intuition for the function named l-e-n-g-t-h that I learned in C programming school in the 1980s" is the best criteria that I have seen, and which commands outright dismissal.
>>
>> This is exactly my criterion (except that I learned English, not C), and I do not agree with you that it "commands outright dismissal". There is value in functions being as general as possible, etc, but there is also value in conforming to human intuitions â€“ because it prevents people from shooting themselves in their feet. Whether those intuitions come from math, or from C, or from English, or elsewhere, is entirely irrelevant. If behavior of `length` fully conforms to your intuitions, that's splendid and you're lucky; however, for me and my usecases it's *only* a source of pain, and I want a way to free myself of that pain (without having to learn another language or spend time trying to change my intuitions).
>>
>> Wanting to make one's life easier is not an unreasonable desire.
>
>
>
> --
> Tony Morris
> http://tmorris.net/
-------------- next part --------------
An HTML attachment was scrubbed...