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?

1 Answer 1

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()
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.