For the other one, it is done through inheritance ...
# arrow
g
For the other one, it is done through inheritance
Copy code
interface FetcherDependencies<F>: MonadThrow<F> {

  fun api(): ApiService

  companion object {
    operator fun invoke(ME: MonadThrow<F>, api: ApiService): FetcherDependencies =
      object: FetcherDependencies, MonadThrow<F> by ME {
        override fun api() = api
      }
  }
}
e
This is a definition of typeclass, which has behaviors of another typeclass, along with a constructor to create an object with such behavior
g
@Egor Trutenko can u pls explain with an example, or using the above example
e
Sorry for long answer Basically, you are right, it is a syntax class. The reason it implements MonadThrow is because it gives you opportunities to use MonadThrow features while inside of it (so it essentially becomes MonadThrow instance). For example, if you have a function like this:
Copy code
fun FetcherDependencies<F>.something()
Then, within
something
you can
flatMap
,
throw
etc. and also access
ApiService
through
api()
.
🔝 2