Skip to content

Commit

Permalink
Add inference for fthomas#917
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Mar 5, 2021
1 parent b9b027b commit 7de38fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ private[refined] trait BooleanInference0 extends BooleanInference1 {
implicit def conjunctionCommutativity[A, B]: (A And B) ==> (B And A) =
Inference.alwaysValid("conjunctionCommutativity")

implicit def dontknownhowtocallthis[A, B, C]: (A And B) ==> (A And (B Or C)) =
Inference.alwaysValid("aaaaaaaaaa")

implicit def dontknownhowtocallthis2[A, B, C]: ((A And B) Or (A And C)) ==> A =
Inference.alwaysValid("aaaaaaaaaa")

implicit def conjunctionEliminationR[A, B, C](implicit p1: B ==> C): (A And B) ==> C =
p1.adapt("conjunctionEliminationR(%s)")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import eu.timepit.refined.api.Inference
import eu.timepit.refined.boolean._
import eu.timepit.refined.char.{Digit, Letter, UpperCase, Whitespace}
import eu.timepit.refined.numeric._
import eu.timepit.refined.string._
import eu.timepit.refined.collection._
import org.scalacheck.Prop._
import org.scalacheck.Properties
import shapeless.test.illTyped
Expand All @@ -20,6 +22,14 @@ class BooleanInferenceSpec extends Properties("BooleanInference") {
Inference[Not[Not[UpperCase]], UpperCase].isValid
}

property("example 1") = secure {
Inference[NonEmpty And ValidLong, NonEmpty And (ValidLong Or ValidDouble)].isValid
}

property("example 2") = secure {
Inference[(NonEmpty And ValidLong) Or (NonEmpty And ValidDouble), NonEmpty].isValid
}

property("double negation elimination 2x") = secure {
Inference[Not[Not[Not[Not[UpperCase]]]], UpperCase].isValid
}
Expand Down

0 comments on commit 7de38fd

Please sign in to comment.