Am I missing something here with context receivers...
# arrow
k
Am I missing something here with context receivers? Here is a simple function with 2 context receiver requirements:
Copy code
context(Raise<Error>, Logger)
fun myFunction(value: Int): String {
  debug("this is a debug message")
  ensure(value > 1) {
    Error()
  }
  return "Yay!"
}
Then trying to run the function with applicable scopes fails because it can’t find the required receivers:
Copy code
either {
      with(LoggerFactory.getLogger(this::class.java)) {
        // No required context receiver found: Cxt { context(arrow.core.raise.Raise<kotlin.Error>, org.slf4j.Logger)
        // public fun myFunction(value: <http://kotlin.Int|kotlin.Int>): kotlin.String
        myFunction(3)
      }
    }
It moans that the correct receivers aren’t present. It also highlights that the with block for the logger is unused and not required 👀
Nevermind. It helps that I import the correct LoggerFactory 🤦‍♂️