Closed DivergentClouds closed 1 year ago
By empty alternation, I mean an alternation expression with no arguments. So your example wouldn't count since it has two arguments ` and
.... I think the only reason there's syntax for an empty composition is because I defined the empty expression
to represent a composition with no arguments (extending the idea that
a bcomposes two arguments and
a` composes just one).
Semantically, the empty alternation should be something that behaves as the identity element of the alternation operator (analogously to an empty sum being 0 or an empty product being 1). This is another reason your example wouldn't work. The empty alternation must be a function F
that fails on all inputs, since F | x
= x
and x | F
= x
for all x
. It's possible construct F
like this:
0 { - 0 | }
F { 0 - }
So F
is semantically equivalent to an empty alternation, but I wouldn't call it an empty alternation because it's syntactically very different.
Thinking about this issue when I first wrote this part of the README led me to design an alternative syntax for Unarian which has an elegant syntax for empty alternations. In this alternative syntax, [ a b c ]
represents the composition of a
, b
, c
, and { a b c }
represents the alternation of a
, b
, c
. Then [ ]
is the empty composition and { }
is the empty alternation. Using this syntax, we can write the code above like this:
0 { [ - 0 ] [ ] }
F [ 0 - ]
README.md says
however, it is possible to represent empty alternations syntactically as
{ | ... }
where...
is any further code.