What is the difference between the two definitions

58 views Asked by At

What's the difference between the two definitions?

def f[F[_]: Async](...) = ???

def f[F[_]](...)(implicit F: Async[F]) = ???

later I can use Async[F].async {} in first case and F.async {} in second But i can't figure out the difference. Thx.

1

There are 1 answers

0
Pritam Kadam On

I would say, it is just a matter of personal preference.

One is a syntactic sugar to other, You can go with any one of them and achieve same thing.

Note that, you are able to use this Async[F].async {} just because someone already defined apply method which looks similar to your second option.

If that was not the case, then you had to write it like implicitly[Async[F]].async {}