Skip to content

Commit 83a2ead

Browse files
committed
Add decidable equality function _≟_ to Haskell.Law.Eq.Def
1 parent 7cae101 commit 83a2ead

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Haskell/Law/Eq/Def.agda

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ open import Haskell.Prim.Double
77
open import Haskell.Prim.Eq
88

99
open import Haskell.Extra.Dec
10+
open import Haskell.Extra.Refinement
1011

1112
open import Haskell.Law.Bool
1213
open import Haskell.Law.Equality
@@ -35,6 +36,12 @@ record IsLawfulEq (e : Set) ⦃ iEq : Eq e ⦄ : Set₁ where
3536

3637
open IsLawfulEq ⦃ ... ⦄ public
3738

39+
-- Types with a lawful Eq instance have decidable equality
40+
_≟_ : {{_ : Eq a}} {{_ : IsLawfulEq a}} (x y : a) Dec (x ≡ y)
41+
x ≟ y = (x == y) ⟨ isEquality x y ⟩
42+
43+
{-# COMPILE AGDA2HS _≟_ inline #-}
44+
3845
-- Reflexivity: x == x = True
3946
eqReflexivity : ⦃ iEq : Eq e ⦄ ⦃ IsLawfulEq e ⦄
4047
(x : e) (x == x) ≡ True

0 commit comments

Comments
 (0)