Open Abastro opened 2 years ago
Thanks for bringing this up.
I like your last suggestion the most, but I don't think I'd put the code repair there. There are too many opportunities for it to be wrong and lead the user down a blind alley. (Your suggestion might get the user to nest do
s unnecessarily, or d
might already be bound, or the user might replace (displayList theRest)
with the do
block mentioned, or something else.) I think use `<-` in do notation
is informative enough.
Slightly larger context: I think suggesting repairs is properly the job of HLS, not GHC. HLS has the power to, say, analyze the user's code in the area and find the right fix. (One could even argue that use `<-` in do notation
is something HLS should come up with, but that's a mismatch for current practice.)
Perhaps you would like to bind
displayList theRest
in the do notation.
I like this suggestion a lot, though as a user I would like some clarification around what we mean by "bind", or how to do it (eg in this case it's "use <-
", and that's not obvious the first time around).
I see, so we would better not have fully-fledged suggestion from GHC. At least giving hint to the users & HLS about let
vs. <-
would be nice, tho the wording is p hard. Meh, the naming bind
is not explicit in code..
As far as terminology goes, I would phrase it
Perhaps you meant to bind the result of
foo
with<-
, instead of bindingfoo
itself withlet
?
It is a bit wordy, though.
Wish I were better at building a comprehensible sentence :<
I am quite sure I've seen more cryptic error messages, but for now I can only found simpler ones.
Problem
I noticed that there are many errors coming from confusion between:
vs.
It would be great if we could give a suggestion.
Cases and Errors
StackOverflow search gave a few such cases.
1. Code:
Error message:
2. Code:
Error:
(You know there is no suggestion in
...
part)This one is special in that they are trying to use top-level IO action. still, likely a similar fix.
3. Code:
Error:
Suggestion
Let me consider the last one.
Perhaps add suggestion like this:
(Though, I do not like the word
bind
here)or this: