@@ -121,15 +121,31 @@ automate most of this.
121
121
122
122
* If it is important that certain names only come into scope later in
123
123
the file then the module should still be imported at the top of the
124
- file but it can be given a shorter name using the keyword ` as ` and then
125
- opened later on in the file when needed, e.g.
124
+ file but it can be imported * qualified* , i.e. given a shorter name
125
+ using the keyword ` as ` and then opened later on in the file when needed,
126
+ e.g.
126
127
``` agda
127
128
import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
128
129
...
129
130
...
130
131
open SetoidEquality S
131
132
```
132
133
134
+ * Naming conventions for qualified ` import ` s: if importing a module under
135
+ a root of the form ` Data.X ` (e.g. the ` Base ` module for basic operations,
136
+ or ` Properties ` for lemmas about them etc.) then conventionally, the
137
+ qualified name(s) for the import(s) should (all) share as qualfied name
138
+ that of the name of the ` X ` datatype defined: i.e. ` Data.Nat.Base `
139
+ should be imported as ` ℕ ` , ` Data.List.Properties ` as ` List ` , etc.
140
+ In this spirit, the convention applies also to (the datatype defined by)
141
+ ` Relation.Binary.PropositionalEquality.* ` which should be imported qualified
142
+ with the name ` ≡ ` .
143
+ Other modules should be given a 'suitable' qualified name based on its 'long'
144
+ path-derived name (such as ` SetoidEquality ` in the example above); commonly
145
+ occcurring examples such as ` Algebra.Structures ` should be imported qualified
146
+ as ` Structures ` etc.
147
+ NB. Historical legacy means that these conventions have not always been observed!
148
+
133
149
* When using only a few items (i.e. < 5) from a module, it is a good practice to
134
150
enumerate the items that will be used by declaring the import statement
135
151
with the directive ` using ` . This makes the dependencies clearer, e.g.
@@ -532,3 +548,22 @@ word within a compound word is capitalized except for the first word.
532
548
533
549
* The names of patterns for reflected syntax are also * appended* with an
534
550
additional backtick.
551
+
552
+ #### Specific pragmatics/idiomatic patterns
553
+
554
+ ## Use of ` with ` notation
555
+
556
+ Thinking on this has changed since the early days of the library, with
557
+ a desire to avoid 'unnecessary' uses of ` with ` : see Issues
558
+ [ #1937 ] ( https://github.com/agda/agda-stdlib/issues/1937 ) and
559
+ [ #2123 ] ( https://github.com/agda/agda-stdlib/issues/2123 ) .
560
+
561
+ ## Proving instances of ` Decidable ` for sets, predicates, relations, ...
562
+
563
+ Issue [ #803 ] ( https://github.com/agda/agda-stdlib/issues/803 )
564
+ articulates a programming pattern for writing proofs of decidability,
565
+ used successfully in PR
566
+ [ #799 ] ( https://github.com/agda/agda-stdlib/pull/799 ) and made
567
+ systematic for ` Nary ` relations in PR
568
+ [ #811 ] ( https://github.com/agda/agda-stdlib/pull/811 )
569
+
0 commit comments