simulacrum
simulacrum copied to clipboard
Methods with lazy initial param don’t end up in ops.
@typeclass trait Merge[F[_]] {
def merge[A, B](fa: => F[A], fb: => F[B]): Option[F[(A, B)]]
}
doesn’t have a merge method in the ops class. But if I remove the => before F[A], it works as I’d expect.
The implicit def that's generated requires that F[A] is already evaluated, as well as the Ops itself since self isn't put as lazy on there.
Just out of curiosity what do you expect to be evaluated when you call fa merge fb if a fix is applied?
I would expect fa to be evaluated – I currently manually define the Ops class in this case, so that it looks like
def merge[B](fb: => F[B]): Option[F[(A, B)]] = typeclassInstance.merge(self, fb)
so, self must already be evaluated to a value of type F[A].