crem/docs/how-to-render-a-machine.md
2023-04-06 11:12:04 +02:00

2.5 KiB

How to render a machine

The other operation that we might be interested in performing when we have a machine :: StateMachine a b is obtaining a graphical representation of it to understand better how it works and maybe using it as documentation and/or as a starting point for a discussion with a domain expert.

Currently, there are two representations which crem is able to create.

State space rendering

The first representation which you can obtain it the representation as a graph of the topology of a machine.

The only supported output format for the moment is Mermaid, and you can produce it composing the machineAsGraph and renderUntypedGraph functions from the Render module.

For example, this is the graph produced for the LockDoor machine

lock door machine

Flow rendering

Rendering the state space for big machines could be quite uninformative, because it could easily get quite big.

A possibly more useful representation is provided by the flow representation (i.e. a graph showing the state space of each Basic machine and how they were composed) which can be generated using the renderFlow function from the RenderFlow module.

To be called, it requires us to annotate every leaf of our tree of machines with a label, which will be used in the drawing.

Then it will produce a diagram like

risk manager flow

which will show the flow of the composed machine and, in every box, the state space representation for every single composed machine.