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

content script now doesn't rewrite code as refmt errors #92

Merged
merged 2 commits into from
Jun 3, 2018

Conversation

dvisztempacct
Copy link
Contributor

@dvisztempacct dvisztempacct commented May 10, 2018

Feedback would be greatly appreciated!

Edit: The main reason for this PR was to address the extension's behavior when a syntax error occurs. In master branch, the behavior is to destroy the original source code on your page by replacing it with an error message. This PR fixes that. A future PR could improve it further by putting the error message some place the user can find it.

improved Refmt2:

  • eliminated Refmt2.refmtJS
  • Refmt2.refmt now uses bs-result

protocol improved:

  • made refmt message serialization format more friendly:
    • using string for tag instead of integer
    • using jsConverter for payload record

limitations:

  • Refmt2.refmt really needs a more complex result type to report degree
    of success or failure
  • code on page should contain the error message somewhere, maybe in a
    tooltip

improved Refmt2:
- eliminated Refmt2.refmtJS
- Refmt2.refmt now uses bs-result

protocol improved:
- made refmt message serialization format more friendly:
  - using string for tag instead of integer
  - using jsConverter for payload record

limitations:
- Refmt2.refmt really needs a more complex result type to report degree
  of success or failure
- code on page should contain the error message somewhere, maybe in a
  tooltip
@chenglou chenglou requested a review from rickyvetter May 21, 2018 18:44
Copy link
Collaborator

@rickyvetter rickyvetter left a comment

Choose a reason for hiding this comment

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

Thanks for this! Definitely a needed improvement.

We also need a production build before landing.

@@ -54,7 +54,9 @@ let getBlacklist = () => [
"mwhittaker.github.io/distributed-systems-ocaml/code_MorePipes.html" /* #49 */
];

let getWhitelist = () => [];
let getWhitelist = () => [
"codebad.com/~hdon/reason-tools-test.html"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding this test!

| a => (UnknownLang, UnknownLang, Obj.magic(a))
| a => {
Js.log("hdon sez: refmt2 is error");
Result.Error(a |> Printexc.to_string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem to be giving very useful responses. Everything gets printed as Failure(_) when I try. I think this can be fixed in a followup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's definitely got some limitations. I was hoping to get some feedback about it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I think Printexc.print gives more control over the actual output here so we can make sure things look nice.

@@ -38,6 +38,7 @@
},
"devDependencies": {
"bs-platform": "^2.2.1",
"bs-result": "^1.1.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks! Much more reliable.

type payload = {
outText: string,
inLang: language,
outLang: language
};
type response = result(payload, string);
type response = Result.t(payload, string);
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I compile this code I get an error here. It looks like it should be Result.result(string, payload);

I'm guessing it is a version issue for bs-result?

@rickyvetter rickyvetter merged commit e5d845d into reasonml:master Jun 3, 2018
@@ -1,22 +1,19 @@
open Core;

module Refmt = {
let refmt = Refmt2.refmtJS;
let refmt = Refmt2.refmt;
let parse =
Copy link

Choose a reason for hiding this comment

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

Why not use Result.map?

let parse = Result.map(((inlang, outLang, outText)) =>
  Protocol.Refmt.{ outText, inLang, outLang };

type result('a, 'e) =
| Ok('a)
| Error('e);
open Result;
Copy link

@scull7 scull7 Jun 4, 2018

Choose a reason for hiding this comment

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

No need for the open since all the Result namespace is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah IDK why that's there :3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@ELLIOTTCABLE
Copy link

Any chance we could get a bamp-release to AMO, so we can close #91? I've currently gotta keep the extension disabled, and manually re-enable it every time I have a use for it! <3

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.

4 participants