crem-0.1.0.0: Compositional representable executable machines
Safe HaskellSafe-Inferred
LanguageGHC2021

Crem.Render.Render

Description

Once you defined a StateMachineT, you can render its topology as a directed graph using a Mermaid state diagram

Synopsis

Documentation

newtype Mermaid Source #

Mermaid is just a newtype around Text to specialize it to Mermaid diagrams

Constructors

Mermaid 

Fields

Instances

Instances details
Semigroup Mermaid Source #

Notice that we joining two non-empty mermaid diagrams, a newline will be added

Instance details

Defined in Crem.Render.Render

Show Mermaid Source # 
Instance details

Defined in Crem.Render.Render

Eq Mermaid Source # 
Instance details

Defined in Crem.Render.Render

Methods

(==) :: Mermaid -> Mermaid -> Bool #

(/=) :: Mermaid -> Mermaid -> Bool #

newtype MachineLabel Source #

A MachineLabel is just a newtype around Text to represents label which will be attached to every leaf of the tree defined by the constructors of StateMachineT

Constructors

MachineLabel 

Fields

Instances

Instances details
IsString MachineLabel Source # 
Instance details

Defined in Crem.Render.Render

Show MachineLabel Source # 
Instance details

Defined in Crem.Render.Render

Eq MachineLabel Source # 
Instance details

Defined in Crem.Render.Render

renderStateDiagram :: (RenderableVertices a, Show a) => Graph a -> Mermaid Source #

We can render a Graph as a Mermaid state diagram

labelVertex :: Show a => MachineLabel -> a -> Text Source #

Prepends a MachineLabel to the Show output, as a Text

renderLabelledVertices :: forall a. (Show a, RenderableVertices a) => MachineLabel -> Graph a -> Mermaid Source #

Render all the vertices of a graph after labelling all of them

renderVertices :: forall a. (Show a, RenderableVertices a) => Graph a -> Mermaid Source #

Render all vertices with no label

renderLabelledEdges :: Show a => MachineLabel -> Graph a -> Mermaid Source #

Render all the edges of a graph after labelling all of them

renderEdges :: Show a => Graph a -> Mermaid Source #

Render all edges with no label

renderGraph :: (RenderableVertices a, Show a) => Graph a -> Mermaid Source #

Render a Graph with no labels

baseMachineAsGraph :: forall vertex topology input output m. (Demote vertex ~ vertex, SingKind vertex, SingI topology) => BaseMachineT m (topology :: Topology vertex) input output -> Graph vertex Source #

Interpret a BaseMachine as a Graph using the information contained in its topology.

This is the point where we make usage of the machinery provided by the singletons library, which require us to impose the constraints we have on vertex and topology

renderUntypedStateDiagram :: UntypedGraph -> Mermaid Source #

Render an UntypedGraph to the Mermaid format

machineAsGraph :: StateMachineT m input output -> UntypedGraph Source #

Interpret a StateMachine as an UntypedGraph using the information contained in its structure and in the topology of its basic components