Finite state machine written in OCaml to test for the sequence 0,1
I notice that you represent states as functions. This does give some expressive power, as seen in the composition example given in your linked answer.

If that power isn't needed we can write things directly and simply:

type element = Z | O

let rec start list = look_for_zero list

and look_for_zero = function
  | [] -&gt; "nothing"
  | Z::rest -&gt; have_zero rest
  | O::rest -&gt; look_for_zero rest

and have_zero = function
  | [] -&gt; "nothing"
  | O::_ -&gt; "yes!"
  | Z::rest -&gt; look_for_zero rest


If you want to stick with the given framework, then you can simplify a bit and transform into a functional style:

type ('state, 'number) state_machine = {
  initial: 'state;
  final: 'state -&gt; string;
  transition: 'state -&gt; 'number -&gt; 'state; (* I changed the order! *)
};;

type state = Init | HaveZero | FoundZeroOne
type element = Zero | One

let final = function
  | Init | HaveZero -&gt; "no"
  | FoundZeroOne -&gt; "yes"

let transition state n =
  match n, state with
  | _, FoundZeroOne -&gt; FoundZeroOne
  | Zero, _ -&gt; HaveZero
  | One, Init -&gt; Init
  | One, HaveZero -&gt; FoundZeroOne

let machine = {
  initial = Init;
  final;
  transition;
}

let run_machine machine list =
  machine.final
    (List.fold_left machine.transition machine.initial list)