StoneCypher / fsl

Finite State Language specification
9 stars 1 forks source link

Version 6: poly-type template #1166

Open StoneCypher opened 2 years ago

StoneCypher commented 2 years ago

Back in the flow days, the template took two types, not one - one for the underlying data type, and one for the node type

These days there are a lot of opportunities for types, and most of them won't show up together. The node type, the action type, the data type, the input and output tape types, and more.

In 6, we should probably have an object that passes in the subordinated types. This means we'll need to figure out a notation for type defaults, so that states are strings-unless-we-say-otherwise, et cetera.

One interesting thing about this would be checking the states and actions against the provided type - if it's not string but rather an alternation of string literals. In that way, multiple machines could be held to a shared communications standard.

A notation like this would be nice:

const tape_inputs  = [troll, treasure, empty, goblin, door],
      tape_outputs = [attack, run, defend, bash, open, sneak],
      machine      = sm<{ inputs: tape_inputs, outputs: tape_outputs }>`...`;