*)
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 "";
*)
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
| "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
| ':' ->
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)
| '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)