jcberentsen / elm-wiring-diagrams / Cartesian

A module for cartesian structure

This is an experiment in organizing wiring diagrams

We're not implementing this paper exactly, but finding some inspiration:

The Cost of Compositionality: A High-Performance Implementation of String Diagram Composition

https://arxiv.org/abs/2105.09257

Types


type alias C a =
Internal.C a

The type of a cartesian structure

This is not your typical category theory monoidal thing, as we store a recursive structure


type alias Interface =
Internal.Interface.Interface

The Interface type describes the Arity of the cartesian system structure

Usage

before : C a -> C a -> C a

Put one structure before another

The structures will be dependent and must match in the interface

Note the order of arguments are flipped to support this syntax:

a |> before b

This will put a 'first'

aside : C a -> C a -> C a

Put two structures aside each other

The structures will be independent

Note the order of arguments are flipped to support this syntax:

a |> aside b

This will put a 'first'

init : a -> C a

Initialize a simple 1->1 arity morphism with label 'a'

initWith : Basics.Int -> Basics.Int -> a -> C a

Initialize a morphism with a given interface and label

unit : C a

The unit value

This is possibly not needed, but we'll start off using it.

This may disappear later.

group : C a -> C a

Group a structure

This may be used to group substructures

interface : C a -> Interface

Extract the outermost interface of the structure

wrap : a -> C a -> C a

Wrap a part of the structure with a label a

Convert the inner labels

map : (a -> b) -> C a -> C b

Map a function over all the label a's