Skip to content

Commit 46e6cc1

Browse files
Merge pull request #356 from haskellfoundation/tool-recommendations
Add docs for tool developers
2 parents 346a33d + 0bedd37 commit 46e6cc1

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Haskell tooling emits a variety of errors, warnings, and other messages. In the
55

66
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on improving the site. Thanks!
77

8+
If you're a Haskell tool developer who would like to integrate your project with the site, please refer to [tool-developers.md](./tool-developers.md) for recommendations regarding the error codes themselves.
9+
810
## Running Locally
911

1012
The site is built with the [Hakyll](https://jaspervdj.be/hakyll/) static site generator. To view the site locally, enter the `message-index` directory and run:

tool-developers.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Recommendations for Tool Developers
2+
3+
The Haskell Error Index was started to document GHC error messages, but it will ideally be able to document messages from a variety of Haskell-related tooling.
4+
After all, users don't necessarily know which tool produced a given message.
5+
This document describes the expectations regarding error and warning codes for tools that would like to use this site, along with some recommended but not required practices.
6+
7+
## The Site
8+
9+
[errors.haskell.org](https://errors.haskell.org) is a community-driven site that maintains a collection of documentation for the errors and warnings that Haskell tools can emit.
10+
The site is intentionally low-tech - it consists of a collection of example files and Markdown-formatted explanations, wrangled into HTML, CSS, and JavaScript by Hakyll.
11+
The idea is that even quite new users will be able to submit updates to the site by using something like GitHub's online editor to create a pull request, and that those who want to work on the site don't first need to learn a complicated workflow or special tooling.
12+
13+
## Error Codes
14+
15+
To use this site, your tool should tag each documentable error or warning with a unique code in the form `[ABC-12345]`.
16+
Here, `ABC` is a _namespace_ that is unique to your tool, and `12345` stands for a number.
17+
18+
The most important principle of error codes is that they exist primarily as a means of communication with users.
19+
The code links the output in the user's IDE or terminal to text that describes the error or warning.
20+
Codes should follow these principles:
21+
* A code should always have the same meaning forever
22+
* Codes may be retired or introduced in new releases
23+
24+
Aside from that, tools may assign codes however they wish, and need not do anything but begin emitting them.
25+
There is an optional, recommended code assignment strategy later in this document.
26+
27+
Error codes are associated with the _meaning_ of a message, rather than its text.
28+
As a tool evolves over time, codes should change if and only if the meaning of the message has changed.
29+
That is, rephrasing a message or modifying its presentation should not result in a new code.
30+
Splitting one message into two should result in at least one new code: if one of the new messages is a natural continuation of the prior one and one is a specific special case, then the special case should get a new code, but if neither is clearly the successor, then the prior code should be retired and fresh codes should be assigned to each of the new messages.
31+
Like most forms of communication, this is a matter for human judgment that can't be automatically enforced.
32+
33+
### Error Code Lifecycle
34+
35+
Because error codes exist in a project-administered namespace, there is no need to check in with anyone else to start emitting a new error code.
36+
A new release may add or remove as many codes as the developers wish, so long as a code is never used with two completely different meanings.
37+
There is no obligation to document every error code prior to a release.
38+
The codes are an opportunity for community members to help out, not a new obligation for busy tool developers.
39+
40+
Once a project has committed to the meaning of a code (typically by merging a PR that emits it into their `main` or `master` branch, but the specifics are up to each project), the message index will accept documentation.
41+
Users and develoeprs need not wait for a release to begin documenting error codes.
42+
43+
### Namespaces
44+
45+
The Haskell Foundation administers the error code namespaces - please open an issue here or have a chat with the HF executive team to get a namespace assignment.
46+
The currently assigned namespaces are:
47+
48+
| Namespace | Tool |
49+
|-----------|--------------------------------------|
50+
| `GHC` | [GHC](https://www.haskell.org/ghc/) |
51+
52+
53+
### Code Assignment Recommendations
54+
55+
We recommend that code assignment by a project follow these principles:
56+
57+
1. Codes should not themselves reflect an ontology of messages (that is, don't use one numeric range for type errors, another for parser errors, another for optimizer errors).
58+
This is for a few reasons: codes may move between features over time but still have the same meaning (that is, the implementation of the tool should not be its interface), a sub-region may run out of codes, and sorting related messages together may make it harder to select the right one from a list.
59+
60+
2. Codes should not be assigned sequentially based on the tool's source code, because this will likely seem to reflect an ontology and be misleading, and because sequentially assigned numbers are not very visually distinct.
61+
62+
3. For tools that have long-lived development branches, there should be some mechanism in place to make code conflicts with other branches either obvious or unlikely, to decrease the risk of accidental re-use and/or spurious merge conflicts.
63+
64+
The strategy chosen for GHC was to uniformly sample codes from 0 to 99999, which satisfies all these principles.
65+
Please feel free to do what makes sense for your project.

0 commit comments

Comments
 (0)