|
|
|
|
|
by hu3
617 days ago
|
|
I found this code interesting (not sarcasm) in demo/boiling.ml: let increase_level t =
let level =
match t.level with
| No_Fire -> One_Fire
| One_Fire -> Two_Fires
| Two_Fires -> Three_Fires
| Three_Fires -> Three_Fires
in
{ t with level }
;;
let decrease_level t =
let level =
match t.level with
| No_Fire -> No_Fire
| One_Fire -> No_Fire
| Two_Fires -> One_Fire
| Three_Fires -> Two_Fires
in
{ t with level }
;;
|
|
It would simplify these two functions to just `succ` and `pred`
[1]: https://hackage.haskell.org/package/base-4.20.0.1/docs/GHC-E...