write_canonical

Meaning of {curly brakets} in Prolog

Since Prolog is a homo-iconic language, everything is a term. Therefore, we are sure that {a,b,c} is also a term.

Let’s check SWI-Prolog REPL:

?- functor({a,b,c},F,N).
F = {},
N = 1.

so, {a,b,c} it’s just a compound, and a,b,c its argument:

?- {a,b,c} =.. Syntax.
Syntax = [{}, (a, b, c)].

also write_canonical helps when exploring syntax details :

?- write_canonical({a,b,c}).
{','(a,','(b,c))}

SWI-Prolog extension, dicts, uses {} to build object representation…