Skip to content

Commit

Permalink
refactored to lift out isEquivalence (#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmckinna authored May 8, 2024
1 parent f90617b commit 9c2aca1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Function/Relation/Binary/Setoid/Equality.agda
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Function.Relation.Binary.Setoid.Equality {a₁ a₂ b₁ b₂ : Level}
open import Function.Bundles using (Func; _⟨$⟩_)
open import Relation.Binary.Definitions
using (Reflexive; Symmetric; Transitive)
open import Relation.Binary.Structures
using (IsEquivalence)

private
module To = Setoid To
Expand All @@ -33,17 +35,16 @@ sym = λ f≈g → To.sym f≈g
trans : Transitive _≈_
trans = λ f≈g g≈h To.trans f≈g g≈h

setoid : Setoid _ _
setoid = record
{ Carrier = Func From To
; _≈_ = _≈_
; isEquivalence = record -- need to η-expand else Agda gets confused
{ refl = λ {f} refl {f}
; sym = λ {f} {g} sym {f} {g}
; trans = λ {f} {g} {h} trans {f} {g} {h}
}
isEquivalence : IsEquivalence _≈_
isEquivalence = record -- need to η-expand else Agda gets confused
{ refl = λ {f} refl {f}
; sym = λ {f} {g} sym {f} {g}
; trans = λ {f} {g} {h} trans {f} {g} {h}
}

setoid : Setoid _ _
setoid = record { isEquivalence = isEquivalence }

-- most of the time, this infix version is nicer to use
infixr 9 _⇨_
_⇨_ : Setoid _ _
Expand Down

0 comments on commit 9c2aca1

Please sign in to comment.