Typeclass instances for Reader.
- Alternative
- Defer
- Monad
- Monoid
- Eq
There seems to be an infinite recursion for Reader somewhere. Is this reproducible locally or only on CI (I haven't checked yet)?
There seems to be an infinite recursion for Reader somewhere. Is this reproducible locally or only on CI (I haven't checked yet)?
It's reproducible (although somehow it didn't show up before I submitted the PR). IIRC the problem is that it's impossible to implement a valid Eq instance for Reader because comparing streams requires reading and thus mutating them.
I think the other typeclass instances are (at least from a practical point of view) valid, but the laws can't be tested without a working Eq.
the problem is that it's impossible to implement a valid
Eqinstance forReader
It might of course be possible to implement an invalid one that works well enough for the tests, but I haven't figured out how so far.
the problem is that it's impossible to implement a valid
Eqinstance forReaderIt might of course be possible to implement an invalid one that works well enough for the tests, but I haven't figured out how so far.
For testing you could maybe drain the streams into local variables, compare them and reset the streams with the elements you drained. That is, of course, not a good idea in production, but maybe it's enough in the tests (with documentation why we have to do this).
edit: Some streaming implementation also allow copying/broadcasting a stream without mutating the "original" instance. I don't know if the Twitter ones have this, though.