Retrieve the “dict functor” by defining this predicate:
dict_functor(F) :- compound_name_arguments(_{},F,_).
Then
?- dict_functor(F), compound_name_arity(C,F,5),compound_name_arity(C,N,5).
F = N, N = C'dict',
C = C'dict'(_32692, _32694, _32696, _32698, _32700).
The compound term assembled by compound_name_arity/3 using the dict functor as Name
argument is, indeed, a compound term, but it doesn’t seem to be a dict because
- it’s not written as such and
- has freshvars as keys.
However, is_dict/1 thinks otherwise:
?- dict_functor(F), compound_name_arity(C,F,5),
compound_name_arity(C,N,5),is_dict(C).
F = N, N = C'dict',
C = C'dict'(_36122, _36124, _36126, _36128, _36130).
It is indeed confirmed to be a dict.
That’s probably not right.
Analysis works as expected (dropping information is consistently easier than making up missing information):
?- compound_name_arity(foo{x:1,y:2},Name,Arity).
Name = C'dict',
Arity = 5.
P.S.
compound_name_arity/3 and compound_name_arguments/3 use Name
in the argument list instead of Functor
. I like that … using functor
in 2020 is confusing, seeing how Category Theory is now mainstream. I also note that functor
was already used in the paper “General Theory of Natural Equivalences” by Samuel Eilenberg and Saunders MacLane, 1945. Get out of the way, Prolog!