Wasm-DSL / spectec

Wasm SpecTec specification tools
https://wasm-dsl.github.io/spectec/
Other
26 stars 9 forks source link

Add support for sets? (3, rossberg, ?) #104

Closed 702fbtngus closed 2 months ago

rossberg commented 2 months ago

I have generalised the composition operator ++ to plain sequences and added an element-of operator <- on sequences (which renders as ∈). With that, it's possible to use sequences, i.e. lists, as sets, using ++ for union.

We may want to customise notation to something a little bit more set-looking for the spec document, but that can be done with hints:

def $set(syntax X, X*) hint(show `{X*})
def $set(syntax X, X*) = X*

def $union(syntax X, X_1*, X_2*) hint(show %2 latex("\\cup") %3)
def $union(syntax X, X_1*, X_2*) = X_1* ++ X_2*