Open
Description
Cf. #1937
As well as removing 'redundant' uses of with
, it seems worth flagging as a separate issue the need/desire to exploit the (idiomatics of the) extended capabilities of with
notation throughout the library. Specifically:
- use of nested
with
esp. in conjunction with the next idiom, irrefutablewith
, building up a cascade of dependent inversions until the final RHS proof term may be assembled from the resulting pieces; - use of 'irrefutable'
with
:with <pat> ← <exp> = ...
which avoids having to uncouple the sub-expression<exp>
from the single matching clause... | <pat> = ...
with which the definition then proceeds; there are three distinguished special cases of this, according to the form of<pat>
:
()
or more generally,<constructor> (<constructor>... ()...)
, as a (convenient?) drop-in replacement for more explicit appeals to⊥-elim
orRelation.Nullary.Negation.Core.contradiction
;refl
: such uses seem strictly to extend the capability ofrewrite <exp>
for an<exp>
of types ≡ t
;<pat1> , <pat2> , ... , <patn>
(andrecord
constructors more generally) for extended/nestedΣ
-types; the advantages being that parentheses around the pattern are frequently redundant clutter, but also that such uses may often also permit simplification in the form of replacing the use of an irrefutablewith
pattern with alet <pat1> , <pat2> , ... , <patn> = <exp> in ...
binding instead;
- the use of
with <exp> in <eq>
: this is perhaps more controversial, given the ongoing saga of this notation not precisely offering a drop-in replacement for the hoped-to-be-deprecatedinspect
idiom; nevertheless, all uses ofinspect
have been successfully removed from the library, so the use of this extended form is encouraged where possible; - UPDATED the use of
using <pat> ← <exp> = ...
(since agda v2.7.*) as a proxy for a RHSlet
-binding cf. To let or not to let #2369
Other features/idioms as they arise... with the proposal that at some point (v2.1? v3.0?) we systematically weed out the redundant uses of with
and refactor to take advantage of the above.