here&#x27;s a state machine representing a lock in elm:<p><pre><code>  type State = Locked | Unlocked
  type alias Model = State
  
  lock : Model -&gt; Model
  lock model = Locked
  
  unlock : Model -&gt; Model
  unlock model = Unlocked
  
  open : Model -&gt; Bool
  open model =
    if model = Locked then True else False
</code></pre>
and here it is in erlang:<p><pre><code>  lock(_Lock) -&gt; locked.
  
  unlock(_Lock) -&gt; unlocked.
  
  open(locked) -&gt; false;
  open(unlocked) -&gt; true.
</code></pre>
i think working with state machines in imperative languages is messy, mistake prone and hard to reason about. functional languages are just better for managing state