MystPi / act

🎬 Compose stateful actions to simulate mutable state
https://hexdocs.pm/act
Apache License 2.0
16 stars 1 forks source link

act.flatten #2

Closed darky closed 3 months ago

MystPi commented 3 months ago

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

darky commented 3 months ago

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 commented 3 months ago

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

darky commented 3 months ago

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 commented 3 months ago

Ah, that makes sense!