circuits-diagrams
Safe HaskellNone
LanguageGHC2024

Circuit.Diagram

Description

Generic, untyped string-diagram syntax.

This is the surface that renderers consume. It discards the Haskell types but keeps the layout structure: boxes, wires, bends, swaps, composition and tensor. Constructors live here independently of any particular semantic interpretation (polynomial lenses, matrices, etc.).

Synopsis

Documentation

data SDiagram Source #

Untyped drawing syntax for a string diagram.

This is what a renderer consumes. It discards the Haskell types but keeps the layout structure: boxes, wires, bends, swaps, composition and tensor.

Constructors

SWire

Straight identity wire.

SBox String Int Int

Box with a label, a number of input ports and a number of output ports.

SSpider Int Int

Spider node with an input arity and an output arity (hypergraph junction: all its ports share one wire class).

SPrismBox

Prism box.

SBeside SDiagram SDiagram

Two diagrams side by side (tensor product).

SThenD SDiagram SDiagram

Two diagrams chained (composition).

SBend

Cup (counit): bends two wires back to the unit.

SBend'

Cap (unit): introduces two wires from the unit.

STurn SDiagram

Dual (rotate 180°).

SUnitL

Left unitor I ⊗ A -> A.

SUnitL'

Inverse left unitor A -> I ⊗ A.

SUnitR

Right unitor A ⊗ I -> A.

SUnitR'

Inverse right unitor A -> A ⊗ I.

SAssoc

Associator A ⊗ (B ⊗ C) -> (A ⊗ B) ⊗ C.

SAssoc'

Inverse associator (A ⊗ B) ⊗ C -> A ⊗ (B ⊗ C).

SSwap

Symmetric braiding A ⊗ B -> B ⊗ A.

STrace SDiagram

Trace: hide the last input/output pair as a feedback loop.

A value STrace d represents a diagram d whose last input and last output are connected, removing one port from each boundary.

Instances

Instances details
Eq SDiagram Source # 
Instance details

Defined in Circuit.Diagram

Show SDiagram Source # 
Instance details

Defined in Circuit.Diagram

sCopy :: SDiagram Source #

Copy spider: one input forked to two outputs.

sMerge :: SDiagram Source #

Merge spider: two inputs joined to one output.

sDelete :: SDiagram Source #

Delete spider: erases one input.

sCreate :: SDiagram Source #

Create spider: produces one output from nothing.