simulacrum icon indicating copy to clipboard operation
simulacrum copied to clipboard

Methods with lazy initial param don’t end up in ops.

Open sellout opened this issue 9 years ago • 2 comments

@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.

sellout avatar Apr 30 '16 04:04 sellout

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?

yilinwei avatar May 27 '16 00:05 yilinwei

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].

sellout avatar Nov 27 '16 17:11 sellout