Re:Rethinking Syntax: Binding by Adjacency
by nxobject on Monday March 09, 2026 @04:48PM
(#47315303)
Similarly, Agda has a well-typed mixfix operator syntax – you define a function like (_foo_bar_baz) and can automatically write "X foo Y bar Z baz". It does mean that the operator parser has to be extensible at runtime, but it's not a huge cost for a dependently-typed language.
Re:Rethinking Syntax: Binding by Adjacency
by masfuerte on Monday March 09, 2026 @08:18PM
(#47317626)
Haskell supports user-defined operators (made up of symbols) and also lets you use functions in infix position by surrounding the name in backticks, e.g.
2 `plus` 3
rather than plus 2 3
Re:Rethinking Syntax: Binding by Adjacency
by emptysea on Monday March 09, 2026 @10:27PM
(#47318433)
In Postgres you can define custom operators via `create operator`[0]
-- infix
select a <!!!> b;
-- prefix
select <||> a;
A lot of custom types end up using this [1]. select @-@ '[(0,0),(1,0),(1,1)]'::path;
-- 2
[0] https://www.postgresql.org/docs/current/sql-createoperator.h...
[1] https://www.postgresql.org/docs/current/functions-geometry.h...
This seems like a great attempt. I would be worried about how much parsing and backtracking might be required to infer the infix precedence in a totally general system (like garden-path sentences[1]) or actually ambiguous parse trees (which is cured by adopting some rule like right precedence and parens, but what rule you pick makes some 'natural language' constructions work over others).
[0] https://reference.wolfram.com/language/ref/Infix.html
[1] https://en.wikipedia.org/wiki/Garden-path_sentence