New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent use of seed.next in Cogen instances #285
Comments
@ceedubs I think the call to With regard to |
@adamgfraser thanks for the explanation; that's really helpful. I think that it steers me into a different conclusion than the one that you have presented. Given what you've said, it seems to me like the Therefore I'm inclined to think that the |
@ceedubs I think that makes sense. In the case of |
I agree with @ceedubs -- I agree the Another way to do it would be to instead do something like this: implicit def cogenEither[A, B](implicit A: Cogen[A], B: Cogen[B]): Cogen[Either[A, B]] =
Cogen((seed: Seed, e: Either[A,B]) => e.fold(
a => A.perturb(seed.reseed(0L), a),
b => B.perturb(seed.reseed(1L), b))) For a single disjunction I don't think this is a huge deal, but to support arbitrary coproducts I think using @ceedubs Does this all make sense? |
@non yeah, thanks that makes sense to me. At least conceptually -- I won't claim to understand subtle implications that there might be between calling Do you think we should go ahead and make this change to |
So for now I would stick with the strategy of using In the long-run it may make sense to move to using |
Fixes typelevel#285 (see discussion there).
Fixes typelevel#285 (see discussion there).
Fixes typelevel#285 (see discussion there).
The
Cogen
instances forOption
andEither
both useseed.next
as an argument toperturb
when they are delegating through to an underlyingCogen
instance. See here.It seems to me that there is inconsistent behavior here. For example, the
Either
instance usesseed
when callingperturb
forLeft
s butseed.next
when callingperturb
forRight
s. Also none of the other instances callseed.next
when delegating toperturb
(including the instance forTry
, which is similar toEither
).I'm happy to submit a PR, but I don't think that I understand when
seed.next
should be called (if at all) in these instances. cc @non @rickynilsThe text was updated successfully, but these errors were encountered: