Skip to content

Commit

Permalink
Merge pull request #2 from darky/main
Browse files Browse the repository at this point in the history
  • Loading branch information
MystPi authored Jun 6, 2024
2 parents 771f01f + 70533e6 commit 293ac5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/act.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,13 @@ pub fn try_each(
})
}
}

/// Merges a nested `Action` into a single layer.
///
pub fn flatten(action: Action(Action(b, a), a)) -> Action(b, a) {
fn(state) {
let #(state, action) = action(state)
let #(state, result) = action(state)
#(state, result)
}
}
2 changes: 1 addition & 1 deletion test/act_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ pub fn main() {

io.println("The result is " <> int.to_string(result))
io.println("The state is " <> int.to_string(final_state))
}
}

0 comments on commit 293ac5e

Please sign in to comment.