Module

Data.Operator.Eq

Package
purescript-higher-order
Repository
matthew-hilty/purescript-higher-order

#Eq1 Source

class Eq1 f  where

The Eq1 typeclass of this module represents type constructors f that have an associated equivalence relation of values of type f a independent of any choice of a.

Unlike the Data.Eq.Eq1 typeclass of the 'Prelude' module [hereafter, qualified by the prefix "Prelude"], Eq1, defined here, is not generally equivalent to the Eq typeclass (also found in the 'Prelude' module).

For example, whereas both

eq (Cons 0 Nil) (Cons 1 Nil) == false

and

Prelude.eq1 (Cons 0 Nil) (Cons 1 Nil) == false

the definition found in this module gives the following:

eq1 (Cons 0 Nil) (Cons 1 Nil) == true

That is, the Int values in a value of List Int (and, more generally, the a values in any List a) have little relevance in determining the results of the eq1 function.

The instances of the Eq1 typeclass of this module are designed to emphasize the value-level effects of the type constructors themselves. In practice, this often means that an equivalence relation is assigned to the type constructor's data constructors. The Eq1 instance declaration for List, for example, effectively projects any value of type List a into one of two equivalence classes, where the specific equivalence-class assignment is determined by the data constructor (Cons or Nil) of the value's head deconstruction.

This interpretation of Eq1 exists in addition to Prelude.Eq1 because datatypes often have intrinsic (or designed) subgroupings, commonly distingished by data constructors, and a means to relate these different subgroupings can be useful -- especially in concert with PartialOrd1 and other related typeclasses.

Members

Instances

#GenericEq1 Source

class GenericEq1 a  where

Members

Instances

#(.==) Source

Operator alias for Data.Operator.Eq.eq1 (left-associative / precedence 4)

#notEq1 Source

notEq1 :: forall f a. Eq1 f => f a -> f a -> Boolean

#(./=) Source

Operator alias for Data.Operator.Eq.notEq1 (non-associative / precedence 4)