-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with errors.haskell.org? #5911
Comments
I would be happy to support. There are only 55 occassions of I would, however, like to keep the code short. Could Stack 'claim' the 'S' namespace and Pantry the 'P' namespace? |
I think WRT assigning the numbers, the GHC technique was to uniformly sample them from the space of allowed errors, which reduces the likelihood of conflicts in long-running branches, makes different codes very visually distinct, and doesn't encode any information about the message into the number, which could lead to issues in the future if a sub-namespace runs out of space. Of course, tools that use the error index are free to assign the codes however they want, and the HF is just administering the tool namespaces. |
It probably does not make sense for Pantry to have its own namespace. I guess like any tool that has dependencies, and the dependency throws an error that the tool does not itself deal with, some types of errors arising from the use of Stack will not have codes. EDIT: As Stack is built on top of Cabal (the library), it would be good for Cabal to participate. |
I opened a very similar issue with Cabal: haskell/cabal#8543 It seems plausible to me that really doing this right would involve having more structured representations of errors throughout the ecosystem, so that e.g. an exception handler in an executable that formats errors for display could assign the right code. This would be a nice side effect, but the cost could be too high at the moment. I think a best-effort approach is a good start to making things more useful. |
This is hard. One way I tried in GHCup is to use open sum types (haskus Excepts by @hsyl20). But they quickly get out of hand and you end up building a hierarchy of open sum types (e.g. rewrapping Cabal error type in your own error type). A very unergonomic example of this is: https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/lib/GHCup/Errors.hs#L363 The problem with open sum types are: they're quite unergonomic. I know someone who wrote his thesis about this related topic of error handling in Haskell, maybe he could chime in. I believe a convention will not be enough. It will have to be a library that simply leads programs to having the properties we want. |
Thinking about this further overnight, I realise that I am not across the population of errors that Stack itself reports and their nature. I am planning to document them in this repository, and then take stock. |
Re #5911 Inventory of Stack's errors
I've documented about 240 things that look to me like 'error messages' in Stack's code, at My working definition of an 'error message' was (a) something described as an 'error' and/or (b) something that provides the user with information and causes Stack to terminate without having completed what the user likely hoped for. I am wondering if some tidying up (logical and editorial) may be required before unique codes are assigned to things. |
@hasufell I don't see why open sums are necessary here - doesn't a bog-standard datatype, like they have for GHC's structured errors, do the trick? In a big project like GHC there's four of them, and a type class that describes how to do things like dump them to stderr. Open sums for exceptions are clearly compelling - there's a reason why exceptions are the only open sum in ML, for instance - but for purposes of error message processing an ordinary sum type seems reasonable enough to me. |
That might be worthwhile - I know that @goldfirere spent a bit of time working out the exact assignment of codes to GHC errors, because sometimes further arguments to a sum type actually led to logically different errors. It's also perfectly fine to do error index integration incrementally. If the 30 most common or most important errors are coded and documented, that's already a ton of value, even if many of them remain as strings for some time. |
If it's within your own codebase boundaries and everything else is wrapped and rethrown, certainly. But if you want to observe and pass through errors from, say, Cabal the library in stack, it gets somewhat hairy. I'm just brainstorming. Nothing of this is a blocker for implementing the proposed. |
Re #5911 Tidy up exceptions in Stack.Build
Re #5911 Tidy up exceptions in Stack.Coverage
RE #5911 Tidy up exceptions in Stack.Config
Re #5911 Tidy up exceptions in Stack.ConfigCmd
Re #5911 Tidy up exceptions in Stack.Setup
Re #5911 Tidy up exceptions in Stack.Runners
Re #5911 Tidy up exceptions in Stack.Config.Nix
Re #5911 Tidy up exceptions in Stack.Storage.User
Re #5911 Tidy up exceptions in Stack.Script
Re #5911 Tidy up exceptions in various modules
Re #5911 Add pretty exceptions and use in Stack.Setup
Re #5911 Tidy up exceptions in Main.hs
Re #5911 Tidy up exceptions in Stack.Upload
…other Also prefers `RIO`'s `impureThrow` to `Control.Exception`'s `throw`.
Re #5911 Tidy up exceptions in Stack.SDist, Stack.Hoogle and various other
Stack mostly dealt with its own exceptions by a series of module-specific (closed) sum types that were instances of In some cases, Stack would report a lengthy 'pretty' error and then throw a short 'black and white' exception. It seemed to me that there was a need for a I've realised, belatedly, that Pantry does have its own I think the next thing I need to do is assign error numbers to Stack's exceptions. Following GHC's example, I plan to do that as follows: sample randomly from |
Minor refactoring and Haddock comments.
Re #5911 Tidy up exceptions in various modules
Fix #5911 Apply unique error codes to Stack-generated errors
All errors that Stack itself generates now include a unique "Error: [S-nnnn]" in the output. |
This is really great! I've set up haskellfoundation/error-message-index#358 to track progress on the other side of getting this integrated. Do you know what version number the first Stack release that includes these will have? |
errors.haskell.org presently documents error messages and warnings from GHC, starting with version 9.6.1 once it's released. The design, however, is intended to accommodate any Haskell tooling whatsoever. Would Stack be interested in integrating with the site?
What it entails:
[S-12345]
, where "S" is a namespace (we can talk about what it would be) and "12345" is a number that's unique in that namespaceAs I see it, there'd be the following benefits:
The costs would likely be:
What do you think? Is this interesting?
The text was updated successfully, but these errors were encountered: