Bifunctor instance for (,) is not strictly law-abiding

Edward Kmett ekmett at gmail.com
Wed Feb 17 21:36:45 UTC 2016


Neither one is a pure win.

One can be a bit worse for performance, the other can completely prevent
termination.

-Edward

On Wed, Feb 17, 2016 at 4:35 PM, David Feuer <david.feuer at gmail.com> wrote:

> This is part of what makes lazy State confusing. I haven't really messed
> with Writer too much. The extra laziness can be very bad for performance in
> some cases. Since the laws lead to a different performance intuition, any
> such variance should be documented in Haddock. Note also that fmap and
> second have *different* strictness for pairs, which seems very surprising
> as well.
> On Feb 17, 2016 4:24 PM, "Edward Kmett" <ekmett at gmail.com> wrote:
>
>> As a general rule we let the results of many operations be more defined
>> than the laws require.
>>
>> Stream fusion runs into this exact same "issue".
>>
>> This sort of thing is necessary to makes a lot of things like "lazy
>> state" and "lazy writer" possible at all.
>>
>> -Edward
>>
>> On Wed, Feb 17, 2016 at 2:25 PM, David Feuer <david.feuer at gmail.com>
>> wrote:
>>
>>> I don't think we should fix this, because it would break code, but I do
>>> think we should document it.
>>>
>>> Bifunctor law:
>>>
>>> bimap id id = id
>>>
>>> But actually,
>>>
>>> bimap id id _|_ = (_|_, _|_)
>>>
>>> _______________________________________________
>>> 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/20160217/86cdb3b1/attachment.html>


More information about the Libraries mailing list