Skip to content

Commit 8caaeae

Browse files
committed
Data.Record: drop eta and pattern matching for constructor rec
Future Agda might not allow unguarded record types with eta-equality in `--safe` mode anymore. Re: agda/agda#7470 Switching of eta for `rec` is slightly inconvenient, as was observed already in this issue: agda/agda#840 Allowing it would need improvements to the Agda positivity checker, so that it can recognize `Record` as guarded record that can safely support eta.
1 parent 91e2c01 commit 8caaeae

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

doc/README/Data/Record.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ converse : (P : Record PER) →
3737
Record (PER With "S" ≔ (λ _ P · "S")
3838
With "R" ≔ (λ _ flip (P · "R")))
3939
converse P =
40-
rec (rec (_ ,
40+
rec (rec (rec (rec (rec _ ,) ,) ,
4141
lift λ {_} lower (P · "sym")) ,
4242
lift λ {_} yRx zRy lower (P · "trans") zRy yRx)

src/Data/Record.agda

+21-19
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ mutual
6363
-- inferred from a value of type Record Sig.
6464

6565
record Record {s} (Sig : Signature s) : Set s where
66-
eta-equality
6766
inductive
67+
no-eta-equality
6868
constructor rec
6969
field fun : Record-fun Sig
7070

@@ -122,30 +122,32 @@ Proj (_,_≔_ Sig ℓ′ {A = A} a) ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
122122

123123
-- Record restriction and projection.
124124

125+
open Record renaming (fun to fields)
126+
125127
infixl 5 _∣_
126128

127129
_∣_ : {s} {Sig : Signature s} Record Sig
128130
(ℓ : Label) {ℓ∈ : ℓ ∈ Sig} Restricted Sig ℓ ℓ∈
129131
_∣_ {Sig = ∅} r ℓ {}
130-
_∣_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
131-
... | true = Σ.proj₁ r
132-
... | false = _∣_ (Σ.proj₁ r) ℓ {ℓ∈}
133-
_∣_ {Sig = Sig , ℓ′ ≔ a} (rec r) ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
134-
... | true = Manifest-Σ.proj₁ r
135-
... | false = _∣_ (Manifest-Σ.proj₁ r) ℓ {ℓ∈}
132+
_∣_ {Sig = Sig , ℓ′ ∶ A} r ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
133+
... | true = Σ.proj₁ (fields r)
134+
... | false = _∣_ (Σ.proj₁ (fields r)) ℓ {ℓ∈}
135+
_∣_ {Sig = Sig , ℓ′ ≔ a} r ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
136+
... | true = Manifest-Σ.proj₁ (fields r)
137+
... | false = _∣_ (Manifest-Σ.proj₁ (fields r)) ℓ {ℓ∈}
136138

137139
infixl 5 _·_
138140

139141
_·_ : {s} {Sig : Signature s} (r : Record Sig)
140142
(ℓ : Label) {ℓ∈ : ℓ ∈ Sig}
141143
Proj Sig ℓ {ℓ∈} (r ∣ ℓ)
142144
_·_ {Sig = ∅} r ℓ {}
143-
_·_ {Sig = Sig , ℓ′ ∶ A} (rec r) ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
144-
... | true = Σ.proj₂ r
145-
... | false = _·_ (Σ.proj₁ r) ℓ {ℓ∈}
146-
_·_ {Sig = Sig , ℓ′ ≔ a} (rec r) ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
147-
... | true = Manifest-Σ.proj₂ r
148-
... | false = _·_ (Manifest-Σ.proj₁ r) ℓ {ℓ∈}
145+
_·_ {Sig = Sig , ℓ′ ∶ A} r ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
146+
... | true = Σ.proj₂ (fields r)
147+
... | false = _·_ (Σ.proj₁ (fields r)) ℓ {ℓ∈}
148+
_·_ {Sig = Sig , ℓ′ ≔ a} r ℓ {ℓ∈} with does (ℓ ≟ ℓ′)
149+
... | true = Manifest-Σ.proj₂ (fields r)
150+
... | false = _·_ (Manifest-Σ.proj₁ (fields r)) ℓ {ℓ∈}
149151

150152
------------------------------------------------------------------------
151153
-- With
@@ -170,9 +172,9 @@ mutual
170172
{a : (r : Restricted Sig ℓ ℓ∈) Proj Sig ℓ r}
171173
Record (_With_≔_ Sig ℓ {ℓ∈} a) Record Sig
172174
drop-With {Sig = ∅} {ℓ∈ = ()} r
173-
drop-With {Sig = Sig , ℓ′ ∶ A} {ℓ} (rec r) with does (ℓ ≟ ℓ′)
174-
... | true = rec (Manifest-Σ.proj₁ r , Manifest-Σ.proj₂ r)
175-
... | false = rec (drop-With (Σ.proj₁ r) , Σ.proj₂ r)
176-
drop-With {Sig = Sig , ℓ′ ≔ a} {ℓ} (rec r) with does (ℓ ≟ ℓ′)
177-
... | true = rec (Manifest-Σ.proj₁ r ,)
178-
... | false = rec (drop-With (Manifest-Σ.proj₁ r) ,)
175+
drop-With {Sig = Sig , ℓ′ ∶ A} {ℓ} r with does (ℓ ≟ ℓ′)
176+
... | true = rec (Manifest-Σ.proj₁ (fields r) , Manifest-Σ.proj₂ (fields r))
177+
... | false = rec (drop-With (Σ.proj₁ (fields r)) , Σ.proj₂ (fields r))
178+
drop-With {Sig = Sig , ℓ′ ≔ a} {ℓ} r with does (ℓ ≟ ℓ′)
179+
... | true = rec (Manifest-Σ.proj₁ (fields r) ,)
180+
... | false = rec (drop-With (Manifest-Σ.proj₁ (fields r)) ,)

0 commit comments

Comments
 (0)