From: Amélia Coutard-Sander Date: Wed, 7 Jan 2026 13:38:52 +0000 (+0100) Subject: Inversion des arguments de ModeAndState (mode, puis état) X-Git-Url: https://git.f4mnq.fr/?a=commitdiff_plain;h=c427b37144a7b0681faf100ba1fa600746f3ce88;p=cells.git Inversion des arguments de ModeAndState (mode, puis état) --- diff --git a/bin/main.ml b/bin/main.ml index 10efa2f..1dd33ac 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -14,20 +14,20 @@ *) let run (type state initer) (m : (module Modes.Mode with type state = state and type initer = initer)) (init : initer) = - let rec aux : type state. state -> (module Modes.Mode with type state = state) -> unit = - fun state m -> + let rec aux : type state. (module Modes.Mode with type state = state) -> state -> unit = + fun m state -> let module M = (val m) in M.render state; Graphics.synchronize (); if Graphics.key_pressed () then match M.update state (Graphics.read_key ()) with - | Either.Left state -> aux state m - | Either.Right (ModeAndState (st, m)) -> aux st m - else aux state m + | Either.Left state -> aux m state + | Either.Right (ModeAndState (m, st)) -> aux m st + else aux m state in let module M = (val m) in - aux (M.initial init) (module M) + aux (module M) (M.initial init) let () = Graphics.open_graph ""; diff --git a/bin/modes.ml b/bin/modes.ml index a945fb8..02eeaab 100644 --- a/bin/modes.ml +++ b/bin/modes.ml @@ -14,7 +14,7 @@ *) module rec ModeAux : sig - type mode_and_state = ModeAndState : 'a * (module ModeAux.S with type state = 'a) -> mode_and_state + type mode_and_state = ModeAndState : (module ModeAux.S with type state = 'a) * 'a -> mode_and_state module type S = sig type state @@ -51,7 +51,7 @@ module rec Command : (Mode with type initer = ModeAux.mode_and_state) = struct | "quit" -> Graphics.close_graph (); Either.right old - | "select" -> Either.right (ModeAux.ModeAndState (AutoSelector.initial (), (module AutoSelector))) + | "select" -> Either.right (ModeAux.ModeAndState ((module AutoSelector), AutoSelector.initial ())) | _ -> Printf.fprintf stderr "Unknown cmd: `%s'\n%!" cmd; Either.right old @@ -122,7 +122,7 @@ functor | ':' -> Either.right (ModeAux.ModeAndState - (Command.initial (ModeAux.ModeAndState (st, (module Impl))), (module Command))) + ((module Command), Command.initial (ModeAux.ModeAndState ((module Impl), st)))) | c when '0' <= c && c <= '9' -> Either.left (chnum (int_of_char c - int_of_char '0') st) | 's' -> Either.left (set_current st) | 'q' -> Either.left (ntimes (chcur M.prev) st) @@ -185,7 +185,7 @@ and AutoSelector : (Mode with type initer = unit) = struct | 's' -> let module M = (val curr : Automata.Automaton) in let module NormalM = Normal (M) in - Either.right (ModeAux.ModeAndState (NormalM.initial (), (module NormalM))) + Either.right (ModeAux.ModeAndState ((module NormalM), NormalM.initial ())) | 'q' -> Graphics.close_graph (); Either.left (above, curr, below) diff --git a/bin/modes.mli b/bin/modes.mli index dff6877..202e93d 100644 --- a/bin/modes.mli +++ b/bin/modes.mli @@ -14,7 +14,7 @@ *) module rec ModeAux : sig - type mode_and_state = ModeAndState : 'a * (module ModeAux.S with type state = 'a) -> mode_and_state + type mode_and_state = ModeAndState : (module ModeAux.S with type state = 'a) * 'a -> mode_and_state module type S = sig type state