Skip to content

Commit 98a6a8c

Browse files
jamesmckinnaandreasabel
authored andcommitted
additions to style-guide (#2270)
* added stub content on programming idioms * added para on qualified import names
1 parent e76e213 commit 98a6a8c

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

doc/style-guide.md

+37-2
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,31 @@ automate most of this.
121121

122122
* If it is important that certain names only come into scope later in
123123
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.
126127
```agda
127128
import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
128129
...
129130
...
130131
open SetoidEquality S
131132
```
132133

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+
133149
* When using only a few items (i.e. < 5) from a module, it is a good practice to
134150
enumerate the items that will be used by declaring the import statement
135151
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.
532548

533549
* The names of patterns for reflected syntax are also *appended* with an
534550
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

Comments
 (0)