ohnosequences / stuff

Useful stuff.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Equality #42

Open eparejatobes opened 7 years ago

eparejatobes commented 7 years ago

For Scala:

final
type Eq[A] =
  A × A -> scala.Boolean

final 
class WithEquality[A,E <: Equality](val value: A, val eq: Eq[A])

abstract class Equality {

  final
  type V[A] =
    WithEquality[A,this.type]

  implicit final
  def asV[A](a: A)(implicit eq: Eq[A]): V[A] =
    new WithEquality(a, eq)
}

More generically, this could be done assuming products and truth values. change V[A] to A ⊗ (A ⊗ A -> T) and do everything explicitly. Why not make it explicit too in the Scala case, after all?