Topos Institute
NIST
July 31, 2023
\[ \mathrm{Shp}^\ast(F) = \int^{x \in C} F(c) \times \mathrm{Shp}(c) \]
Let \(C\) be the following small category
\(\mathsf{Set}^C\) is the category of graphs.
Define \(\mathrm{Shp} \colon C^\mathrm{op} \to \mathsf{Top}\) by
\[ E \mapsto [0,1], V \mapsto \ast \] \[ \mathrm{src} \mapsto (\{0\} \subset [0,1]), \mathrm{tgt} \mapsto (\{1\} \subset [0,1]) \]
What if all you needed to do to create a graphical editor for C-sets was to specify \(\mathrm{Shp}\)?
This was the original dream of Semagrams, 2.5 years ago.
Turns out, not so simple.
Designing semagrams is hard… but reimplementing these things from scratch for everything we want edit graphically would also be hard
Semagrams Legacy
Semagrams (current version)
bindings = Seq(
keyDown("s").andThen(a.addAtMouse_(S)),
keyDown("t").andThen(a.addAtMouse_(T)),
keyDown("d").andThen(a.del),
keyDown("E")
.withMods(KeyModifier.Shift)
.andThen(a.importExport),
keyDown("z")
.withMods(KeyModifier.Ctrl)
.andThen(IO(g.undo())),
keyDown("Z")
.withMods(KeyModifier.Ctrl, KeyModifier.Shift)
.andThen(IO(g.redo())),
keyDown("x").andThen(a.importExport),
// ...
)
//...
lg <- IO(
g.signal.map(assignBends(Map(I -> (IS, IT), O -> (OT, OS)), 0.5))
)
_ <- es.makeViewport(
es.MainViewport,
lg,
Seq(
ACSetEntitySource(S, BasicDisc(es)),
ACSetEntitySource(T, BasicRect(es)),
ACSetEdgeSource(I, IS, IT, BasicArrow()(es)),
ACSetEdgeSource(O, OT, OS, BasicArrow()(es))
)
)
ui <- es.makeUI()
_ <- ui.addHtmlEntity(
EquationWindow(),
() =>
PositionWrapper(Position.botMid(15), massActionTypeset(g.signal))
)
//...
def drag[Memo, Return](
start: (z: Complex) => IO[Memo],
during: (Memo, Complex) => Unit,
after: Memo => IO[Return]
): IO[Return] = for {
_ <- IO(m.save())
_ <- IO(m.unrecord())
m0 = m.now()
memo <- es.mousePos.flatMap(start)
ret <- (es.drag.drag(Observer(p => during(memo, p))) >> after(memo))
.onCancelOrError(IO({
m.set(m0)
es.drag.$state.set(None)
}).flatMap(_ => die))
_ <- IO(m.record())
} yield ret
\[ \mathrm{DWD}(F)(n,m) = \sum_{w, b : \mathbb{N}} \sum_{i, o: [b] \to \mathbb{N}} \sum_{\substack{\mathrm{src} \colon [w] \to [n] + \sum_{x : [b]} [o(x)] \\ \mathrm{tgt} \colon [w] \to [m] + \sum_{x : [b]} [i(x)]}} \prod_{x : [b]} F(i(x), o(x))\]