From: Amélia Coutard-Sander <git@ameliathe1st.gay>
Date: Sat, 4 Jan 2025 10:50:31 +0000 (+0100)
Subject: Inversion des arguments de ModeAndState (mode, puis état)
X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=db0d9a14deb1412ad64d0a2f793d0b70a6cb3c06;p=cells.git

Inversion des arguments de ModeAndState (mode, puis état)
---

diff --git a/bin/main.ml b/bin/main.ml
index a33f3bd..5c84bfe 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 80419ea..4ce1aa2 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 7365629..d291e63 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