-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
WIP better error msg #6751
Open
dadhi
wants to merge
35
commits into
roc-lang:main
Choose a base branch
from
dadhi:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WIP better error msg #6751
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
ea23576
feat: better error msg
dadhi 2a17e49
Merge branch 'roc-lang:main' into main
dadhi 33be4d1
Merge branch 'roc-lang:main' into main
dadhi 3a4316d
Merge branch 'roc-lang:main' into main
dadhi 0d680dc
Merge branch 'roc-lang:main' into main
dadhi f6b30a1
Revert "feat: better error msg"
dadhi 5a6de63
Merge branch 'roc-lang:main' into main
dadhi fbaf992
Merge branch 'roc-lang:main' into main
dadhi 17e15e7
Merge branch 'roc-lang:main' into main
dadhi 76d839e
Merge branch 'roc-lang:main' into main
dadhi 2b4aa97
Merge branch 'roc-lang:main' into main
dadhi dc18c14
Merge branch 'roc-lang:main' into main
dadhi 6f2f0c2
Merge branch 'roc-lang:main' into main
dadhi cb1a59c
Merge branch 'roc-lang:main' into main
dadhi bda678f
Merge branch 'roc-lang:main' into main
dadhi d37156d
Merge branch 'roc-lang:main' into main
dadhi 31b51bb
Merge branch 'roc-lang:main' into main
dadhi 5f8a41f
Merge branch 'roc-lang:main' into main
dadhi f6526d3
Merge branch 'roc-lang:main' into main
dadhi 0206f84
Merge branch 'roc-lang:main' into main
dadhi 304cf5d
Merge branch 'roc-lang:main' into main
dadhi 58f2f34
Merge branch 'roc-lang:main' into main
dadhi e0ae6d7
Merge branch 'roc-lang:main' into main
dadhi 66a90b2
Merge branch 'roc-lang:main' into main
dadhi be3a580
Merge branch 'roc-lang:main' into main
dadhi c5644ae
Merge branch 'roc-lang:main' into main
dadhi 5b1c60c
Merge branch 'roc-lang:main' into main
dadhi e05c544
Merge branch 'roc-lang:main' into main
dadhi 972e218
Merge branch 'roc-lang:main' into main
dadhi 78131d5
Merge branch 'roc-lang:main' into main
dadhi 5f9a4fc
Merge branch 'roc-lang:main' into main
dadhi 0d683ca
Merge branch 'roc-lang:main' into main
dadhi 8bc83a8
Merge branch 'roc-lang:main' into main
dadhi dc47d1a
Merge branch 'roc-lang:main' into main
dadhi f227ea2
Merge branch 'roc-lang:main' into main
dadhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea! What if we give an example that doesn't have a simplified version, so there's no need for the second line? For example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rtfeldman Thanks for replying!
In regard to your proposal:
In your example, the closure (lambda) means a different thing comparing to the source of error.
Here is the original error message taken from the tests:
My first attempt at providing the example would be:
It is a good illustration, but if I substitute it into
Num.add 2
it does not make sense.That's why it may be helpful to provide the valid context for the closure, e.g. the pipe operation.
The new idea:
I think we don't need a context if we demonstrate the problem and solution side-by-side.
@rtfeldman What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting!
Thinking about it some more, it occurs to me that people who encounter this message might be in one of a few different scenarios:
undefined
in the function body)I think a lot of people reading the error message in the first two scenarios won't know what "partial application" means, and would actually have a better experience if we didn't bring that up at all - because they might wonder "wait, is partial application something I should be doing here?" when actually they just forgot an argument.
Here's an idea for an error message that might be clearer for people in different scenarios.
Today:
Idea:
I think this wording would be clear for people in all 3 scenarios:
I think the number of people who know what partial application is but don't know how to do it by hand will be very low, so I think this might end up being the most helpful message to people encountering it from different backgrounds!
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I agree that the words of
partial application
should be set aside and more "based" explanation provided:all arguments should be provided
looks good to me.But we still have 2 different contexts for this error: standalone function call and piping.
The problem that the solution hint for the error is different depending on context:
Idea 1 - Split the error in two
Pros:
Cons:
Idea 2 - Keep a single error but provide 2 possible context+solutions
Pros:
Cons:
Ok. I am biased :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so the current advice of "Use a closure to make partial application explicit" is not about pipelines; it's intended to be a message for people who expect functions to be curried.
In other words, in curried languages I can do
List.map nums (Num.add 1)
andNum.add
would be partially applied with1
, but in Roc I would need to "Use the closure syntax to adapt the function call to the required number of arguments" - in other words, write it asList.map nums \num -> Num.add 1 num
instead ofList.map nums (Num.add 1)
(which would produce an error like this today).Does that make sense?