6 -- |Indirect equality comparison.
7 module Data.Eq.Indirect
16 import Prelude.Unicode
18 infix 4 ==:, /=:, ≡:, ≢:, ≠:
20 -- |Type class for indirectly equality-comparable types. That is, any
21 -- @α@ of @'Eq'' α@ has a monomorphism to some
22 -- equality-comparable type @γ@ while @α@ itself isn't
23 -- necessarily an instance of 'Eq'. This way we can generalise the
24 -- '==' operator so that it can take two different types as long as
25 -- they both have monomorphisms to the same 'Eq' type @γ@.
27 -- Minimal complete definition: 'Unified' and 'unify'.
28 class Eq (Unified α) ⇒ Eq' α where
29 -- |The said equality-comparable type @γ@.
31 -- |Monomorphism from @α@ to @γ@.
35 (==:) ∷ (Eq' α, Eq' β, Unified α ~ Unified β) ⇒ α → β → Bool
37 (==:) = (∘ unify) ∘ (≡) ∘ unify
40 (/=:) ∷ (Eq' α, Eq' β, Unified α ~ Unified β) ⇒ α → β → Bool
42 (/=:) = ((¬) ∘) ∘ (==:)
45 (≡:) ∷ (Eq' α, Eq' β, Unified α ~ Unified β) ⇒ α → β → Bool
46 {-# INLINE CONLIKE (≡:) #-}
50 (≢:) ∷ (Eq' α, Eq' β, Unified α ~ Unified β) ⇒ α → β → Bool
51 {-# INLINE CONLIKE (≢:) #-}
55 (≠:) ∷ (Eq' α, Eq' β, Unified α ~ Unified β) ⇒ α → β → Bool
56 {-# INLINE CONLIKE (≠:) #-}