I have to admit I'm not very interested in reading the code. I'm not likely to use this library so I'm more interested in a conceptual understanding than in the details that code requires.

Regarding composition, there are at least three ways to compose FSMs:

* Sequential: when one FSM finishes (reaches a final state) it transitions to the start state of another FSM.

* Parallel: two FSMs transition in parallel from the same input

* Nested: when a FSM reaches a certain state, another FSM starts responding to the input. When the second FSM reaches a final state, control returns to the original FSM.

It would help your description if you were clear about the kinds of composition your library supports. The terminology of FSMs is quite consistent and well defined, so I think you should be able to use it to describe what the library does.

Is there a way to combine:

Higher order finite state machines that require other states as parameters to work.

https://github.com/sdzx-1/ray-game/blob/master/src/select.zi...

The select, inside, and hover states here are all high-level states, and all require two state parameters. And these three states form a small state machine for handling mouse interactive selection.

Can I think of this way of using higher-order state machines as a kind of composition? A semantic composition.

From this perspective, do you think my previous description is accurate?