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

iterateN #20

Merged
merged 8 commits into from
Mar 25, 2022
Merged

iterateN #20

merged 8 commits into from
Mar 25, 2022

Conversation

matthewleon
Copy link
Contributor

@matthewleon matthewleon commented Feb 7, 2018

Create an Unfoldable by repeated application of a function to a seed value.

Create an Unfoldable by repeated application of a function to a seed value.
JordanMartinez
JordanMartinez previously approved these changes Sep 23, 2021
@JordanMartinez
Copy link
Contributor

Hm... CI is failing because Unfoldable1, which already defines its version of singleton and range, is also exported from the Unfoldable module. So, it exports two members with the same name twice.

Merging this would require a breaking change.

@JordanMartinez JordanMartinez added the type: breaking change A change that requires a major version bump. label Sep 23, 2021
@JordanMartinez JordanMartinez added the purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 label Mar 25, 2022
@JordanMartinez JordanMartinez dismissed their stale review March 25, 2022 21:44

iterateN should be updated to use Unfoldable1 and be re-exported by Unfoldable

@JordanMartinez
Copy link
Contributor

Since Unfoldable1 is a super class of Unfoldable, all types that implement Unfoldable (e.g. Array) also implement Unfoldable1. However, the reverse (e.g. NonEmptyArray) is not the case.

iterateN can be redefined to use Unfoldable1 and get the same behavior. See this gist: https://try.purescript.org/?gist=8b4cd9f94df2189ea0ec15c55309911e

@JordanMartinez
Copy link
Contributor

This also explains why singleton and range are re-exported from Data.Unfoldable1 and do not have a separate definition using Unfoldable.

@JordanMartinez JordanMartinez added type: enhancement A new feature or addition. and removed type: breaking change A change that requires a major version bump. purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 labels Mar 25, 2022
@JordanMartinez
Copy link
Contributor

🏓 @thomashoneyman

@thomashoneyman
Copy link
Member

Is there a reason or precedent for the *N suffix, as opposed to just naming this iterate?

@JordanMartinez
Copy link
Contributor

I think iterateN is similar to Haskell. Consider:

@JordanMartinez JordanMartinez merged commit 852e82e into purescript:master Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants