Skip to content
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

Graceful error handling in daml repl #4673

Merged
merged 2 commits into from
Feb 24, 2020
Merged

Graceful error handling in daml repl #4673

merged 2 commits into from
Feb 24, 2020

Conversation

cocreature
Copy link
Contributor

This PR changes daml repl to handle errors (parse errors, type
errors, unsupported statement errors, script errors) gracefully
and just emit an error message instead of tearing down the whole
process.

This gets the repl into a state where I think it’s sufficiently
user-friendly to be released (obviously there are tons of potential
improvements). The only thing missing before I’m comfortable
mentioning this in release notes and uninternalizing it are docs.
If you think there is something crucial that needs to be addressed
before, let me know.

changelog_begin
changelog_end

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

This PR changes `daml repl` to handle errors (parse errors, type
errors, unsupported statement errors, script errors) gracefully
and just emit an error message instead of tearing down the whole
process.

This gets the repl into a state where I think it’s sufficiently
user-friendly to be released (obviously there are tons of potential
improvements). The only thing missing before I’m comfortable
mentioning this in release notes and uninternalizing it are docs.
If you think there is something crucial that needs to be addressed
before, let me know.

changelog_begin
changelog_end
@cocreature cocreature requested review from a user and aherrmann-da February 24, 2020 16:02
Copy link
Contributor

@aherrmann-da aherrmann-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

, matchOutput "^.*: 1"
]
, testInteraction' "type error"
[ input "1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more intuitive if a raw, pure expression did not result in a type error, but instead caused a debug to be inserted automatically, turning it into a Script _ expression. I think we should try to reserve "type errors" in the repl for non-pure expressions (e.g. tried to use Update monad instead of Script monad), or for pure expressions that have type errors in them (e.g. passed an argument of the wrong type). This is way more work than should be in this PR, though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(As for how to implement that, we could catch type errors with "expected Script", add a debug, and try again. Maybe that's kinda messy, but I think it would make the interface more accessible.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully agree that this would be a nicer UX! GHCi also prints the result if you have something of type IO a where a is an instance of Show (and not ()) which would be nice to have. It also has some magic defaulting to IOwhich makes things likepure 1work automagically (that’s the main reason why I currently have the type annotation toScript _`. Not sure how much more clever that is than typechecking twice and if it’s possible to adapt this for our usecase.

@cocreature cocreature merged commit 2a05611 into master Feb 24, 2020
@cocreature cocreature deleted the repl-parse-error branch February 24, 2020 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants