[m-users.] Why does the standard library not define many multi-mode functions?

Philip White philip at pswhite.org
Tue Oct 19 09:26:25 AEDT 2021


One of the advantages of logic programming, in my understanding, is
that by defining computation in terms of relations, you both reduce the
amount of implementation that you have to do, and you can reduce the
size of your API. For example, [find_and_remove] and [add] are just two
ways of looking at the same relation defined on sets. Even if the
implementation of these two modes has to be different for performance
or other reasons, the [map] module could still expose them under the
same predicate by using [promise_equivalent_clauses]. Doing that then
enables any user of the [map] module to write relations with multiple
modes that only require a single implementation.

Thus, I'm a little saddened whenever I look at the mercury standard
library APIs. It seems to me that, although many predicates have a
bunch of different determinisms, and some have different modes, most of
the time the API looks quite similar in structure to a functional
language's API, and it appears very difficult to write multi-mode
predicates over maps.

Is there a reason for why the standard library doesn't take advantage
of logic programming more?

Thanks,
Philip


More information about the users mailing list