Module

Hylograph.Flow

Package
purescript-hylograph-flow
Repository
afcondon/purescript-hylograph-flow

One shared "flow" value: things that hold a value (items) and things that compute (steps), wired together, as in Build Systems a la Carte's store and tasks. Domain detail rides in the item, step and wire parameters and is never inspected here. A flow with nothing to say about its wires has Unit there; one whose wires carry a quantity (a Sankey's widths) has the quantity.

What is drawn is not in the value: project takes a Drawing. Run state is not in the value: see Hylograph.Flow.Overlay. Grouping is not in the value: see Hylograph.Flow.Grouping. Shapes of steps over collections live one layer up, in Hylograph.Flow.Collection.

#ItemId Source

newtype ItemId

Constructors

Instances

#StepId Source

data StepId

Which step. StepId: a step of the source, by the name the source gave it. GroupStep: the one step a closed group became under collapse. They are different constructors, so no name a source can give a step is the identity of a group, whatever the name's letters.

Constructors

Instances

#PortName Source

data PortName

Which port of a step. PortName: a port of the source's own step. MemberPort: a port of a closed group, which is a port of one of its members seen from outside: the member and the member's port. The member may itself be a closed group and its port a MemberPort, where a flow already collapsed is collapsed again.

Constructors

Instances

#GroupId Source

newtype GroupId

Which group, of a grouping beside a flow (Hylograph.Flow.Grouping). Here, and not there, because a closed group's step is named by it.

Constructors

Instances

#stepLabel Source

stepLabel :: StepId -> String

A step's id as words for a reader: the source's name, or group: and the group's. For display only: two different ids can read the same (a step the source named group:G and the closed group G), so nothing is to be keyed or compared by it.

#portLabel Source

portLabel :: PortName -> String

A port as words for a reader: the source's name, or the member's label, a dot, and the member's port. For display only, as stepLabel is.

#Flow Source

newtype Flow item step wire

Constructors

Instances

#Item Source

type Item item = { count :: Int, id :: ItemId, name :: Maybe String, payload :: item }

What holds a value: a column, a file, a stream, a store. name is Nothing only where the source gives the thing no name (a radio stream, a chart's link). count: how many values it holds side by side.

#Step Source

type Step step = { id :: StepId, inputs :: Array PortName, name :: Maybe String, outputs :: Array PortName, payload :: step }

What computes.

#WireId Source

data WireId

Which wire: its two ends and the port at the step end. This is a wire's whole identity; what it carries is no part of it.

Constructors

Instances

#Wire Source

type Wire wire = { id :: WireId, payload :: wire }

A wire and what it carries, shaped as an item and a step are: an id and a payload. The payload is Unit where there is nothing to say.

#plain Source

plain :: WireId -> Wire Unit

A wire that carries nothing.

#wireEnds Source

wireEnds :: WireId -> { from :: ElementKey, to :: ElementKey }

The two elements a wire joins, in the direction it runs.

#Imported Source

type Imported misfit item step wire = { flow :: Flow item step wire, misfits :: Array misfit }

A freshly imported flow and what the importer found that does not fit.

#unFlow Source

unFlow :: forall item step wire. Flow item step wire -> { items :: Array (Item item), steps :: Array (Step step), wires :: Array (Wire wire) }

#mapPayloads Source

mapPayloads :: forall i i' s s' w w'. (i -> i') -> (s -> s') -> (w -> w') -> Flow i s w -> Flow i' s' w'

#erase Source

erase :: forall i s w. Flow i s w -> Flow Unit Unit Unit

#ElementKey Source

data ElementKey

Any element of a flow, for drawing and for overlays. A wire is keyed by its identity, never by what it carries.

Constructors

Instances

#Drawing Source

data Drawing

Which elements a picture draws as nodes. Every element not drawn is contracted: an edge runs between two drawn elements for each path of wires between them through undrawn ones.

  • Holders: items are nodes, each step becomes edges (a spreadsheet's columns, a Makefile's files).
  • Steps: steps are nodes, each item becomes edges (a radio's blocks).
  • Both: the bipartite graph, every wire an edge.
  • Chosen: the caller says, element by element. Added beyond the three agreed cases, because two subjects (Makefile phony targets drawn among files; the rig chart's stores drawn among its processes) draw some of each kind, and none of the three reproduces them.

Constructors

#drawnBy Source

drawnBy :: Drawing -> ElementKey -> Boolean

Whether a drawing draws an element as a node.

#Node Source

type Node = { inputs :: Array PortName, key :: ElementKey, label :: String, outputs :: Array PortName }

A drawn element. label: its name, or its id where it has none. inputs, outputs: a step's ports (empty for an item).

#Edge Source

type Edge wire = { from :: ElementKey, fromPort :: Maybe PortName, to :: ElementKey, toPort :: Maybe PortName, via :: Array ElementKey, wires :: NonEmptyArray (Wire wire) }

via: the undrawn elements the edge passes through, from source to target. fromPort: the port it leaves a drawn step by; toPort: the port it enters a drawn step by. wires: the wires the edge stands for, each with its identity and what it carries, from source to target. They are a path: the first leaves from, the last enters to, and each one between meets the next at an element of via. An edge is at least one wire: exactly one where the edge is a wire (Both), two where it crosses one undrawn element. A wire on several paths is in several edges. (Hylograph.Flow.Laws states all of this as a function.)

#Projection Source

type Projection wire = { edges :: Array (Edge wire), nodes :: Array Node }

#project Source

project :: forall i s w. Drawing -> Flow i s w -> Projection w

Nodes in array order, items before steps. Edges in the order of the wire that enters their target.

#problems Source

problems :: forall i s w. Flow i s w -> Array Problem

Every wire names an existing item, step and port; each item has at most one writer; ids are unique, a wire's too (two wires with one identity could not be told apart by an overlay).

#writerOf Source

writerOf :: forall i s w. Flow i s w -> ItemId -> Array { payload :: w, port :: PortName, step :: StepId }

#readersOf Source

readersOf :: forall i s w. Flow i s w -> ItemId -> Array { payload :: w, port :: PortName, step :: StepId }

#layers Source

layers :: forall w. Projection w -> Map ElementKey Int

Longest path from a node with no incoming edge, over the projection. Self-loops are ignored; nodes on a cycle get the layer they had when the cycle was met.

#leafMass Source

leafMass :: forall w. Projection w -> Map ElementKey (Set ElementKey)

Per node, the set of nodes with no incoming edge that reach it (itself, for such a node).

#isolated Source

isolated :: forall w. Projection w -> Array ElementKey

Nodes no edge touches, in node order.