Hylograph.Flow.Grouping
- Package
- purescript-hylograph-flow
- Repository
- afcondon/purescript-hylograph-flow
Grouping beside a flow, never in it: a nested partition of step ids (a
rose tree whose leaves are steps), and collapse, which draws a cut
through it. Each closed group becomes one step; the items only its
members write and read are hidden; every other wire is re-attached to the
group, by a port that is the member and its port (MemberPort), and
wires left parallel are merged into one.
A closed group's step is GroupStep of the group's id and its ports are
MemberPorts, constructors no step or port of a source has. So whatever
the source's steps and ports are called, none is taken for a group's,
and a flow already collapsed can be collapsed again: a Member may name
a GroupStep. (The one thing left to the caller: a second cut must not
reuse the id of a group the first cut closed, unless it holds that
group's step.)
One mechanism for a radio's fused runs, for semantic zoom, and for the rig chart's machines opened into their voices.
#collapse Source
collapse :: forall i s w. Semigroup w => Array Grouping -> Set GroupId -> Flow i s w -> Flow i (Collapsed s) wThe coarser flow for a cut: the groups in closed are drawn shut; a
closed group shuts everything under it; an open one is transparent.
Parallel wires are merged: where several members of a closed group read one item that stays visible, the group reads it by one wire, at the port of the first of them, carrying what they carried, combined in wire order. (Likewise for writes, and for any two wires left with one identity.) The group keeps no port for a wire merged away. So between a closed group and an item there is at most one wire each way, and no two wires of the coarser flow share an identity.
Semigroup, not a function argument: the merge has to be associative
for the result not to depend on how the wires happen to be bracketed,
which is the one law the class states, and Unit already has it.