Skip to content

Commit 90260db

Browse files
WhatisRTomelkonian
authored andcommitted
Add DecEq-Refinement
Contributed by @HeinrichApfelmus
1 parent 7915f0f commit 90260db

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Class/DecEq/Instances.agda

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private
2626
∷-injective : {x y xs ys}
2727
(List⁺ A ∋ x ∷ xs) ≡ y ∷ ys x ≡ y × xs ≡ ys
2828
∷-injective refl = (refl , refl)
29+
2930
module _ ⦃ _ : DecEq A ⦄ where instance
3031
DecEq-List⁺ : DecEq (List⁺ A)
3132
DecEq-List⁺ ._≟_ (x ∷ xs) (y ∷ ys)
@@ -44,6 +45,15 @@ module _ ⦃ _ : DecEq A ⦄ where instance
4445
DecEq-Maybe ._≟_ = M.≡-dec _≟_
4546
where import Data.Maybe.Properties as M
4647

48+
open import Data.Refinement
49+
50+
-- Equality for a Refinement type is decide if the equality
51+
-- for the type to be refined is decidable.
52+
DecEq-Refinement : {p} {P : A Set p} DecEq (Refinement A P)
53+
DecEq-Refinement ._≟_ (x , px) (y , py) with x ≟ y
54+
... | no neq = no (neq ∘ cong value)
55+
... | yes refl = yes refl
56+
4757
module _ ⦃ _ : DecEq A ⦄ ⦃ _ : DecEq B ⦄ where
4858

4959
-- Not exported as instance so that users can also choose `Class.DecEq.WithK.DecEq-Σ`

0 commit comments

Comments
 (0)