Skip to content

Commit 2f84dcc

Browse files
authored
[ deprecate ] Relation/Binary.PropositionalEquality.inspect and README.Inspect (#1580 / #1630 / #1930 redux) (#2981)
* remove: module `README.Inspect` * refactor: deprecate module `README.Inspect` * refactor: introduce `Graph`; deprecate `Reveal`, `[_]`, `inspect` * `CHANGELOG` * fix : `README.Data.Wrap` by narrowing `import`s
1 parent 0742c7d commit 2f84dcc

5 files changed

Lines changed: 78 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The library has been tested using Agda 2.8.0.
66
Highlights
77
----------
88

9+
### Deprecated `Relation.Binary.PropositionalEquality.inspect`, in favour
10+
of `with ... in ...` syntax (issue #1580; PRs #1630, #1930, #2934)
11+
12+
* In `Relation.Binary.PropositionalEquality`, the record type `Reveal_·_is_`
13+
and its principal mode of use, `inspect`, have been deprecated in favour of
14+
the new `with ... in ...` syntax. See the documentation of [with-abstraction equality](https://agda.readthedocs.io/en/stable/language/with-abstraction.html#with-abstraction-equality).
15+
916
Bug-fixes
1017
---------
1118

@@ -131,6 +138,13 @@ Deprecated names
131138
decidable ↦ _∪?_
132139
```
133140

141+
* In `Relation.Binary.PropositionalEquality`:
142+
```agda
143+
Reveal_·_is_ ↦ Graph.View
144+
inspect ↦ Graph.view
145+
pattern [_] ↦ λ eq → record { fx≡y = eq }
146+
```
147+
134148
* In `Relation.Nullary.Decidable.Core`:
135149
```agda
136150
⊤-dec ↦ ⊤?
@@ -658,6 +672,17 @@ Additions to existing modules
658672
¬[x≢x] : .(x ≢ x) → Whatever
659673
```
660674

675+
* In `Relation.Binary.PropositionalEquality`, replacing `Reveal`/`inspect`:
676+
```agda
677+
module Graph {A : Set a} {B : A → Set b} (f : (x : A) → B x) (x : A) where
678+
679+
record View (y : B x) : Set (a ⊔ b) where
680+
field fx≡y : f x ≡ y
681+
682+
view : View (f x)
683+
view = record { fx≡y = refl }
684+
```
685+
661686
* In `Relation.Nullary.Negation.Core`
662687
```agda
663688
¬¬-η : A → ¬ ¬ A

doc/README.agda

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ import README.Debug.Trace
241241

242242
import README.Nary
243243

244-
-- Explaining the inspect idiom: use case, equivalent handwritten
245-
-- auxiliary definitions, and implementation details.
246-
247-
import README.Inspect
248-
249244
-- Explaining how to use the automatic solvers
250245

251246
import README.Tactic.MonoidSolver

doc/README/Data/Wrap.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module Instances where
108108

109109
module Unification where
110110

111-
open import Relation.Binary.PropositionalEquality
111+
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
112112

113113
module Naïve where
114114

doc/README/Inspect.agda

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
------------------------------------------------------------------------
22
-- The Agda standard library
33
--
4-
-- Explaining how to use the inspect idiom and elaborating on the way
5-
-- it is implemented in the standard library.
4+
-- This module is DEPRECATED.
5+
--
6+
-- The record type `Reveal_·_is_`, and its principal mode of use,
7+
-- via the `inspect` function described below, have been deprecated
8+
-- in favour of the `with ... in ...` syntax. See the documentation
9+
--
10+
-- https://agda.readthedocs.io/en/stable/language/with-abstraction.html#with-abstraction-equality
611
------------------------------------------------------------------------
712

813
{-# OPTIONS --cubical-compatible --safe #-}
914

1015
module README.Inspect where
1116

17+
{-# WARNING_ON_IMPORT
18+
"README.Inspect was deprecated in v2.4."
19+
#-}
20+
1221
open import Data.Nat.Base
1322
open import Data.Nat.Properties
1423
open import Data.Product.Base using (_×_; _,_)
1524
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
16-
open import Relation.Binary.PropositionalEquality using (inspect; [_])
25+
import Relation.Binary.PropositionalEquality as ≡ using (inspect; [_])
1726

1827
------------------------------------------------------------------------
1928
-- Using inspect
@@ -72,9 +81,9 @@ plus-eq-+ (suc m) n = refl
7281
-- the second one is trivial.
7382

7483
plus-eq-with : m n Plus-eq m n (m + n)
75-
plus-eq-with m n with m + n | inspect (m +_) n
76-
... | zero | [ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0
77-
... | suc p | [ m+n≡1+p ] = m+n≡1+p
84+
plus-eq-with m n with m + n | ≡.inspect (m +_) n
85+
... | zero | ≡.[ m+n≡0 ] = m+n≡0⇒m≡0 m m+n≡0 , m+n≡0⇒n≡0 m m+n≡0
86+
... | suc p | ≡.[ m+n≡1+p ] = m+n≡1+p
7887

7988

8089
------------------------------------------------------------------------

src/Relation/Binary/PropositionalEquality.agda

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ naturality : ∀ {x y} {x≡y : x ≡ y} {f g : A → B}
6262
(f≡g : x f x ≡ g x)
6363
trans (cong f x≡y) (f≡g y) ≡ trans (f≡g x) (cong g x≡y)
6464
naturality {x = x} {x≡y = refl} f≡g =
65-
f≡g x ≡⟨ sym (trans-reflʳ _) ⟩
65+
f≡g x ≡⟨ trans-reflʳ _
6666
trans (f≡g x) refl ∎
6767
where open ≡-Reasoning
6868

@@ -71,9 +71,9 @@ naturality {x = x} {x≡y = refl} f≡g =
7171
cong-≡id : {f : A A} {x : A} (f≡id : x f x ≡ x)
7272
cong f (f≡id x) ≡ f≡id (f x)
7373
cong-≡id {f = f} {x} f≡id = begin
74-
cong f fx≡x ≡⟨ sym (trans-reflʳ _) ⟩
75-
trans (cong f fx≡x) refl ≡⟨ cong (trans _) (sym (trans-symʳ fx≡x)) ⟩
76-
trans (cong f fx≡x) (trans fx≡x (sym fx≡x)) ≡⟨ sym (trans-assoc (cong f fx≡x)) ⟩
74+
cong f fx≡x ≡⟨ trans-reflʳ _
75+
trans (cong f fx≡x) refl ≡⟨ cong (trans _) (trans-symʳ fx≡x)
76+
trans (cong f fx≡x) (trans fx≡x (sym fx≡x)) ≡⟨ trans-assoc (cong f fx≡x)
7777
trans (trans (cong f fx≡x) fx≡x) (sym fx≡x) ≡⟨ cong (λ p trans p (sym _)) (naturality f≡id) ⟩
7878
trans (trans f²x≡x (cong id fx≡x)) (sym fx≡x) ≡⟨ cong (λ p trans (trans f²x≡x p) (sym fx≡x)) (cong-id _) ⟩
7979
trans (trans f²x≡x fx≡x) (sym fx≡x) ≡⟨ trans-assoc f²x≡x ⟩
@@ -92,26 +92,15 @@ module _ (_≟_ : DecidableEquality A) {x y : A} where
9292

9393

9494
------------------------------------------------------------------------
95-
-- Inspect
95+
-- The graph view of a function
9696

97-
-- Inspect can be used when you want to pattern match on the result r
98-
-- of some expression e, and you also need to "remember" that r ≡ e.
97+
module Graph {A : Set a} {B : A Set b} (f : (x : A) B x) (x : A) where
9998

100-
-- See README.Inspect for an explanation of how/why to use this.
99+
record View (y : B x) : Set (a ⊔ b) where
100+
field fx≡y : f x ≡ y
101101

102-
-- Normally (but not always) the new `with ... in` syntax described at
103-
-- https://agda.readthedocs.io/en/v2.6.4/language/with-abstraction.html#with-abstraction-equality
104-
-- can be used instead."
105-
106-
record Reveal_·_is_ {A : Set a} {B : A Set b}
107-
(f : (x : A) B x) (x : A) (y : B x) :
108-
Set (a ⊔ b) where
109-
constructor [_]
110-
field eq : f x ≡ y
111-
112-
inspect : {A : Set a} {B : A Set b}
113-
(f : (x : A) B x) (x : A) Reveal f · x is f x
114-
inspect f x = [ refl ]
102+
view : View (f x)
103+
view = record { fx≡y = refl }
115104

116105

117106
------------------------------------------------------------------------
@@ -130,3 +119,30 @@ isPropositional = Irrelevant
130119
Please use Relation.Nullary.Irrelevant instead. "
131120
#-}
132121

122+
-- Version 2.4
123+
124+
module _ {A : Set a} {B : A Set b} where
125+
126+
open Graph
127+
128+
Reveal_·_is_ : (f : (x : A) B x) (x : A) (y : B x) Set (a ⊔ b)
129+
Reveal f · x is y = View f x y
130+
131+
inspect : (f : (x : A) B x) (x : A) Reveal f · x is f x
132+
inspect = view
133+
134+
pattern [_] eq = record { fx≡y = eq }
135+
{-# WARNING_ON_USAGE [_]
136+
"Warning: [_] was deprecated in v2.4.
137+
Please use the `with ... in eq` syntax instead. "
138+
#-}
139+
{-# WARNING_ON_USAGE inspect
140+
"Warning: inspect was deprecated in v2.4.
141+
Please use the `with ... in eq` syntax described at
142+
https://agda.readthedocs.io/en/stable/language/with-abstraction.html#with-abstraction-equality instead."
143+
#-}
144+
{-# WARNING_ON_USAGE Reveal_·_is_
145+
"Warning: Reveal_·_is_ was deprecated in v2.4.
146+
Please use the `with ... in eq` syntax described at
147+
https://agda.readthedocs.io/en/stable/language/with-abstraction.html#with-abstraction-equality instead."
148+
#-}

0 commit comments

Comments
 (0)