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

act.flatten #2

Merged
merged 2 commits into from
Jun 6, 2024
Merged

act.flatten #2

merged 2 commits into from
Jun 6, 2024

Conversation

darky
Copy link
Contributor

@darky darky commented Jun 5, 2024

No description provided.

@MystPi
Copy link
Owner

MystPi commented Jun 5, 2024

What is this function generally used for? I can't think of anything off the top of my head.

@darky
Copy link
Contributor Author

darky commented Jun 5, 2024

flatten unnest nested Action to one level

Result analog - https://hexdocs.pm/gleam_stdlib/gleam/result.html#flatten
Option analog - https://hexdocs.pm/gleam_stdlib/gleam/option.html#flatten

In another FP programming languages sometimes it's called chain

@MystPi
Copy link
Owner

MystPi commented Jun 5, 2024

I mean more of a practical use-case that one would typically use this function for. The function itself makes sense.

@darky
Copy link
Contributor Author

darky commented Jun 5, 2024

For example, you use act.map on some Action and inside this act.map you change State via act/state.set
On result, you receive Action(Action) and you want unnest it before sending it to next function in pipeline

@MystPi
Copy link
Owner

MystPi commented Jun 5, 2024

Ah, that makes sense!

test/act_test.gleam Show resolved Hide resolved
@darky darky requested a review from MystPi June 5, 2024 21:00
@MystPi MystPi merged commit 293ac5e into MystPi:main Jun 6, 2024
1 check failed
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.

2 participants