This commit is contained in:
Alexander Heldt
2025-11-08 14:35:35 +01:00
parent 74e8c6d6dc
commit c2bd0afb7d

View File

@@ -21,7 +21,13 @@ pub fn apply_rules(
rule3: fn(Game) -> Result(Game, String),
rule4: fn(Game) -> Result(Game, String),
) -> Game {
case rule2(game) |> rule1 |> result.try(rule3) |> result.try(rule4) {
game
|> rule1
|> result.map(rule2)
|> result.try(rule3)
|> result.try(rule4)
|> fn(result) {
case result {
Error(err) -> Game(..game, error: err)
Ok(g) ->
case g.player {
@@ -29,4 +35,5 @@ pub fn apply_rules(
White -> Game(..g, player: Black)
}
}
}
}