Module

DataViz.Layout.StateMachine.Types

Package
purescript-hylograph-layout
Repository
afcondon/purescript-hylograph-layout

DataViz.Layout.StateMachine.Types

Types for state machine visualization. A state machine diagram shows states as circles/ovals and transitions as labeled arrows between them.

Both states and transitions carry an extra payload, and the two are independently parameterised: a state's payload describes a state (a phase, a liveness flag), a transition's payload describes an edge (the event that fires it, a guard, a refusal reason). A caller that wants neither uses Unit for both.

#State Source

type State extra = { extra :: extra, id :: String, isFinal :: Boolean, isInitial :: Boolean, label :: String }

A state in the state machine The extra field allows attaching arbitrary data (e.g., phantom type info)

#Transition Source

type Transition extra = { extra :: extra, from :: String, label :: String, to :: String }

A transition between states The extra field carries whatever the caller needs to keep attached to the edge itself — the triggering event, a guard, a refusal reason — so that a renderer can style or annotate an arrow without a side table keyed by from/to/label.

#StateMachine Source

type StateMachine stateExtra transitionExtra = { states :: Array (State stateExtra), transitions :: Array (Transition transitionExtra) }

Complete state machine definition

#StatePosition Source

type StatePosition = { cx :: Number, cy :: Number, rx :: Number, ry :: Number }

Computed position for a state

#TransitionPath Source

type TransitionPath = { angle :: Number, controlX :: Number, controlY :: Number, endX :: Number, endY :: Number, isSelfLoop :: Boolean, labelX :: Number, labelY :: Number, startX :: Number, startY :: Number }

Computed path for a transition arrow Uses quadratic bezier for curved arrows

#LayoutState Source

type LayoutState extra = { position :: StatePosition, state :: State extra }

A state with computed layout

#LayoutTransition Source

type LayoutTransition extra = { path :: TransitionPath, transition :: Transition extra }

A transition with computed layout

#StateMachineLayout Source

type StateMachineLayout stateExtra transitionExtra = { height :: Number, initialArrow :: { angle :: Number, x :: Number, y :: Number }, originX :: Number, originY :: Number, states :: Array (LayoutState stateExtra), transitions :: Array (LayoutTransition transitionExtra), width :: Number }

Complete layout output ready for rendering originX/originY are the top-left of the drawing, which is NOT always (0, 0): a self-loop or a transition label can sit left of or above the leftmost state, and a viewBox pinned to the origin clips them. Renderers should use all four as the viewBox.