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

[ramda] Cleanup definitions #3733

Merged
merged 2 commits into from
Feb 17, 2020
Merged

[ramda] Cleanup definitions #3733

merged 2 commits into from
Feb 17, 2020

Conversation

moroine
Copy link
Contributor

@moroine moroine commented Feb 15, 2020

Other notes:

  • Change function params to $ReadOnlyArray as ramda does not modify input
  • Remove usage of any & Object

Should fix #3561

@moroine
Copy link
Contributor Author

moroine commented Feb 15, 2020

@AndrewSouthpaw @LoganBarnett could you have a look at it?

@LoganBarnett
Copy link
Contributor

@moroine I think these are good changes. One thing I would stipulate is Ramda functions should accept $ReadOnlyArray and return Array. This allows the consumer to use either type as they like. $ReadOnlyArray is not actually a truly immutable array. Using the type is only a promise that you won’t mutate the array within the context of the type. I’m writing this from a phone, but it’s pretty easy to take a Array and pass it into something that takes a $ReadOnlyArray, and mutate the Array immediately afterwards.

Another reason to type inputs as $ReadOnlyArray and output Array is so any other libraries or even your codebase itself can interop with Ramda.

If you need more examples, we have a few open PRs for Ramda currently that are using this paradigm. I didn’t get a thorough look at the PR yet, but I’m pretty sure one of those covers chain already. I’ll take a look when I get back to my machine.

Regarding the input and output types, does that sound reasonable to you?

@LoganBarnett
Copy link
Contributor

Oh. Looks you’re covering Chain instead of chain. And you are returning Array. That’s what I get for reading a diff from a tiny phone. Disregard my post.

@moroine
Copy link
Contributor Author

moroine commented Feb 16, 2020

@LoganBarnett nice description of $ReadOnlyArray usage. To add more details on why we should always use ReadOnlyArray as param and Array as the return value is because ramda return a new instance.

Also as a side note, I tried many way to remove deprecated type *, especially in curry definitions but I don't think it's possible. I tried to propose a PR on flowJs which would make this possible but unfortunately I don't think it will be merged facebook/flow#8201 😢

Copy link
Contributor

@AndrewSouthpaw AndrewSouthpaw left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for the review @LoganBarnett

@AndrewSouthpaw AndrewSouthpaw merged commit 3a4276e into flow-typed:master Feb 17, 2020
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.

[ramda] last should be OK with getting a $ReadOnlyArray as argument
3 participants