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

Move forEach from Array to Task to Avoid Cyclic Dependency #126

Open
NickSeagull opened this issue Feb 20, 2025 · 0 comments
Open

Move forEach from Array to Task to Avoid Cyclic Dependency #126

NickSeagull opened this issue Feb 20, 2025 · 0 comments
Assignees
Labels
breaking effort: 1 Takes roughly 1 hour (w/ docs+testing) good first issue Good for newcomers package: core Related to the core libraries state: approved type: chore work: obvious Straightforward tasks with known solutions; follow best practices

Comments

@NickSeagull
Copy link
Contributor

Currently, the forEach method is defined in the Array module and is responsible for iterating over each element while executing an IO action. However, in NeoHaskell, side-effectful functions should use Task instead of IO.

Attempting to fix this by importing Task into the Array module leads to a cyclic dependency. To resolve this, forEach should be moved to the Task module and implemented using the Traversable type class. This would allow forEach to work generically over any collection type that supports traverse, ensuring proper separation of concerns and avoiding cyclic dependencies.

Expected Solution

  • Move the forEach implementation from Array to Task.
  • Modify forEach to use Traversable instead of being specific to Array.
  • Ensure forEach can be used in for loops over any collection that implements Traversable.
  • Remove the now-unnecessary implementation of forEach in Array.

Additional Context

This change aligns with NeoHaskell's design philosophy by ensuring that effectful computations use Task, rather than IO, and by leveraging Traversable to generalize the iteration process.

@NickSeagull NickSeagull self-assigned this Feb 20, 2025
@NickSeagull NickSeagull added breaking good first issue Good for newcomers package: core Related to the core libraries type: chore effort: 1 Takes roughly 1 hour (w/ docs+testing) state: approved work: obvious Straightforward tasks with known solutions; follow best practices labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking effort: 1 Takes roughly 1 hour (w/ docs+testing) good first issue Good for newcomers package: core Related to the core libraries state: approved type: chore work: obvious Straightforward tasks with known solutions; follow best practices
Projects
None yet
Development

No branches or pull requests

1 participant