diff --git a/docs/abstraction-diagrams.md b/docs/abstraction-diagrams.md index 5ed16eb4e..cb005f15b 100644 --- a/docs/abstraction-diagrams.md +++ b/docs/abstraction-diagrams.md @@ -9,9 +9,10 @@ sidebar_label: "Abstraction Diagrams" ```mermaid classDiagram Absorption~A~ <|-- DistributiveAbsorption~A~ - Absorption~A~ <|-- Involution~A~ Absorption~A~ <|-- Noncontradiction~A~ Absorption~A~ <|-- ExcludedMiddle~A~ + ExcludedMiddle~A~ <|-- Involution~A~ + Noncontradiction~A~ <|-- Involution~A~ class Absorption~A~{ () or(=> A, => A): A () and(=> A, => A): A @@ -20,20 +21,17 @@ classDiagram Boolean Set[A] } - class Involution~A~{ - Boolean - () complement(=> A): A - } class Noncontradiction~A~{ - Boolean () complement(=> A): A () bottom: A } class ExcludedMiddle~A~{ - Boolean () complement(=> A): A () top: A } + class Involution~A~{ + Boolean + } ``` diff --git a/experimental-laws/shared/src/main/scala/zio/prelude/experimental/laws/InvolutionLaws.scala b/experimental-laws/shared/src/main/scala/zio/prelude/experimental/laws/InvolutionLaws.scala index 9546afc04..bfcd8bb7c 100644 --- a/experimental-laws/shared/src/main/scala/zio/prelude/experimental/laws/InvolutionLaws.scala +++ b/experimental-laws/shared/src/main/scala/zio/prelude/experimental/laws/InvolutionLaws.scala @@ -25,6 +25,6 @@ object InvolutionLaws extends Lawful[InvolutionEqual] { * The set of all laws that instances of `Involution` must satisfy. */ lazy val laws: Laws[InvolutionEqual] = - AbsorptionLaws.laws + involutionLaw + ExcludedMiddleLaws.laws + NoncontradictionLaws.laws + involutionLaw } diff --git a/experimental/shared/src/main/scala/zio/prelude/experimental/Absorption.scala b/experimental/shared/src/main/scala/zio/prelude/experimental/Absorption.scala index 8f04d2624..d6ee02b48 100644 --- a/experimental/shared/src/main/scala/zio/prelude/experimental/Absorption.scala +++ b/experimental/shared/src/main/scala/zio/prelude/experimental/Absorption.scala @@ -17,14 +17,8 @@ object Absorption { */ def apply[A](implicit absorption: Absorption[A]): Absorption[A] = absorption - implicit lazy val BoolInstance: DistributiveAbsorption[Boolean] - with ExcludedMiddle[Boolean] - with Involution[Boolean] - with Noncontradiction[Boolean] = - new DistributiveAbsorption[Boolean] - with ExcludedMiddle[Boolean] - with Involution[Boolean] - with Noncontradiction[Boolean] { + implicit lazy val BoolInstance: DistributiveAbsorption[Boolean] with Involution[Boolean] = + new DistributiveAbsorption[Boolean] with Involution[Boolean] { override def complement(a: => Boolean): Boolean = !a override val bottom: Boolean = false override val top: Boolean = true diff --git a/experimental/shared/src/main/scala/zio/prelude/experimental/ExcludedMiddle.scala b/experimental/shared/src/main/scala/zio/prelude/experimental/ExcludedMiddle.scala index 5a79a6efd..127187cc7 100644 --- a/experimental/shared/src/main/scala/zio/prelude/experimental/ExcludedMiddle.scala +++ b/experimental/shared/src/main/scala/zio/prelude/experimental/ExcludedMiddle.scala @@ -10,7 +10,7 @@ trait ExcludedMiddle[A] extends Complement[A] { object ExcludedMiddle { /** - * Summons an implicit `Complement[A]`. + * Summons an implicit `ExcludedMiddle[A]`. */ def apply[A](implicit excludedMiddle: ExcludedMiddle[A]): ExcludedMiddle[A] = excludedMiddle } diff --git a/experimental/shared/src/main/scala/zio/prelude/experimental/Involution.scala b/experimental/shared/src/main/scala/zio/prelude/experimental/Involution.scala index 411206b6a..c1cb839d5 100644 --- a/experimental/shared/src/main/scala/zio/prelude/experimental/Involution.scala +++ b/experimental/shared/src/main/scala/zio/prelude/experimental/Involution.scala @@ -1,7 +1,7 @@ package zio.prelude package experimental -trait Involution[A] extends Complement[A] +trait Involution[A] extends ExcludedMiddle[A] with Noncontradiction[A] object Involution { diff --git a/experimental/shared/src/main/scala/zio/prelude/experimental/coherent/coherent.scala b/experimental/shared/src/main/scala/zio/prelude/experimental/coherent/coherent.scala index 56a3a95fb..6a037c367 100644 --- a/experimental/shared/src/main/scala/zio/prelude/experimental/coherent/coherent.scala +++ b/experimental/shared/src/main/scala/zio/prelude/experimental/coherent/coherent.scala @@ -65,7 +65,7 @@ object ExcludedMiddleEqual { } } -trait InvolutionEqual[A] extends AbsorptionEqual[A] with Involution[A] +trait InvolutionEqual[A] extends ExcludedMiddleEqual[A] with NoncontradictionEqual[A] with Involution[A] object InvolutionEqual { implicit def derive[A](implicit involution0: Involution[A], equal0: Equal[A]): InvolutionEqual[A] = @@ -77,9 +77,9 @@ object InvolutionEqual { override def and(l: => A, r: => A): A = involution0.and(l, r) - override def Or: Associative[OrF[A]] = involution0.Or + override def Or: Identity[OrF[A]] = involution0.Or - override def And: Associative[AndF[A]] = involution0.And + override def And: Identity[AndF[A]] = involution0.And protected def checkEqual(l: A, r: A): Boolean = equal0.equal(l, r) }