Skip to content

Commit

Permalink
Add bi-conditional <-->
Browse files Browse the repository at this point in the history
(cherry picked from commit 3896a3e)
  • Loading branch information
cvogt authored and xuwei-k committed Sep 16, 2015
1 parent 3ab9071 commit 27c9821
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/src/main/scala/scalaz/syntax/std/BooleanOps.scala
Expand Up @@ -126,6 +126,19 @@ final class BooleanOps(self: Boolean) {
*/
final def <--(q: => Boolean) = b.inverseConditional(self, q)

/**
* Bi-Conditional.
*
* {{{
* p q p <--> q
* 0 0 1
* 0 1 0
* 1 0 0
* 1 1 1
* }}}
*/
final def <-->(q: => Boolean) = b.conditional(self, q) && b.inverseConditional(self, q)

/**
* Inverse Conditional.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/src/test/scala/scalaz/BooleanSyntaxTest.scala
Expand Up @@ -31,6 +31,13 @@ object BooleanSyntaxTest extends SpecLite {
p <-- q == (p || !q)
}

"bi-conditional" in {
assert(false <--> false)
assert(true <--> true)
assert(!(true <--> false))
assert(!(false <--> true))
}

"negate conditional" ! forAll { (p:Boolean, q:Boolean) =>
p -/> q == (p && !q)
}
Expand Down

0 comments on commit 27c9821

Please sign in to comment.