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

Implement interfaces (issue #40) #42

Merged
merged 1 commit into from Dec 16, 2019
Merged

Implement interfaces (issue #40) #42

merged 1 commit into from Dec 16, 2019

Conversation

seprich
Copy link
Contributor

@seprich seprich commented Dec 6, 2019

No description provided.

@coveralls
Copy link

coveralls commented Dec 6, 2019

Pull Request Test Coverage Report for Build 75

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.71%

Totals Coverage Status
Change from base Build 70: 0.0%
Covered Lines: 136
Relevant Lines: 137

💛 - Coveralls

@gilbert
Copy link
Member

gilbert commented Dec 6, 2019

Just to confirm, these are generated? (It's been a while since I used reason)

@seprich
Copy link
Contributor Author

seprich commented Dec 7, 2019

I used editor plugin type hints (which uses bsb), and wrote manually according to those, however I did change the signature of make from (('a => unit) => 'b) => t('a) into (('a => unit) => unit) => t('a) which makes more sense because the value 'a is the only one which is used or useful. However such a change could break someones code (and required editing on the testing code in this PR) and therefore is not backwards compatible. Another similar, but which I didn't change, is with tapOk and tapError , the function given as second parameter is 'a =>'b so it may return anything, which is not however used for anything. In such case 'a => unit would be IMO more sensible, but again that change could break someones code.

Maybe I should change the signature of make back to the backwards compatible (('a => unit) => 'b) => t('a) form and make a separate PR about sanitizing signatures which could be then evaluated separately?

src/FutureJs.re Outdated
@@ -26,6 +26,7 @@ let fromPromise = (promise, errorTransformer) =>
|> ignore
|> Js.Promise.resolve
)
|> ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this modify the interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it does. Ok I'll change this PR to ensure backwards compatibility

@seprich
Copy link
Contributor Author

seprich commented Dec 8, 2019

The interface is now carefully implemented to be identical with type inference done by bsb, so this PR should be 100% backwards compatible at this point. Assuming though that the implementation details of type t('a); are not intended to be exposed.. I hope that is a sensible assumption.

Copy link
Collaborator

@scull7 scull7 left a comment

Choose a reason for hiding this comment

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

:shipit:

@briangorman
Copy link
Collaborator

The interface is now carefully implemented to be identical with type inference done by bsb, so this PR should be 100% backwards compatible at this point. Assuming though that the implementation details of type t('a); are not intended to be exposed.. I hope that is a sensible assumption.

Did you you create this by using the automatic interface generator?

https://bucklescript.github.io/docs/en/automatic-interface-generation

@scull7
Copy link
Collaborator

scull7 commented Dec 8, 2019

@briangorman why is the automatic creation of the interface file a concern? Standardization?

@briangorman
Copy link
Collaborator

@briangorman why is the automatic creation of the interface file a concern? Standardization?

Just making sure that the interface isn't changing

@scull7
Copy link
Collaborator

scull7 commented Dec 9, 2019

It would be an extraordinary case where the interface could change. And in the case where it would change it would be that the specified interface is more specific than the inference done by bsb. If there's concern over interface incompatibility we should bump the major version number. However, I don't see anything which is different.

@scull7
Copy link
Collaborator

scull7 commented Dec 12, 2019

@briangorman Can we go ahead and merge this?

@briangorman
Copy link
Collaborator

briangorman commented Dec 12, 2019

@scull7 I haven't had time to check this, but if you have taken a look and the interface didn't change I have no problem merging this 👍

@scull7
Copy link
Collaborator

scull7 commented Dec 12, 2019

As far as I can tell, and the tests can tell, the interface has not changed.

@briangorman
Copy link
Collaborator

briangorman commented Dec 13, 2019

The PR looks good. Only thing that seems to differ from the build in generator is the parameter order

e.g.

let map: (t('a), 'a => 'b) => t('b);

versus (generated)

let map: (t('b), 'b => 'a) => t('a); 

Copy link
Collaborator

@briangorman briangorman 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 the PR,

Could you please generate this file by running the bsb inference? The parameter names to functions are ordered differently than those generated by bsb and I think we should try to stay as consistent with community conventions as possible.

e.g.

let map: (t('a), 'a => 'b) => t('b);

versus (generated)

let map: (t('b), 'b => 'a) => t('a); 

Running the inference is very quick.

@briangorman briangorman merged commit 02844a9 into RationalJS:master Dec 16, 2019
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.

None yet

5 participants