0

One of the ways we can bind() in an Arrow monad comprehesion is "yelling" (third example):

/**
 * All possible approaches to running [Kind] in the context of [Fx]
 *
 * ```
 * fx {
 *   val one = just(1).bind() // using bind
 *   val (two) = just(one + 1) // using destructuring
 *   val three = !just(two + 1) // yelling at it
 * }
 * ```
 */

Since Kotlin's ! operator is used to negate a boolean, can you explain how and why it works this way in Arrow?

codependent
  • 23,193
  • 31
  • 166
  • 308

1 Answers1

0

I found the answer in Kotlin's doc about operator overloading: https://kotlinlang.org/docs/reference/operator-overloading.html

BindSyntax overrides the not operator:

interface BindSyntax<F> {

  suspend fun <A> Kind<F, A>.bind(): A

  suspend operator fun <A> Kind<F, A>.not(): A =
    bind()
}
codependent
  • 23,193
  • 31
  • 166
  • 308