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

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 _|_ = (_|_, _|_)

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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

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"
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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

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
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"
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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (2)
-
David Feuer
-
Edward Kmett