[m-users.] A predicate taking a lists of predicates as input?

Tomas By tomas at basun.net
Fri Sep 26 02:56:47 AEST 2025


On Thu, 25 Sep 2025 17:59:03 +0200, Tomas By wrote:
> If you want to express things in an easier way yourself [...] then
> it is very easy to do code conversion in Mercury


Allow me to elaborate. You have rules like this

| r --> ?(r₁, ..., rₙ).

These are in a separate file "my.rules".

Then you define a Mercury type

| myrule ---> r ; '?'(list(myrule)).

(or something, as appropriate)

After that, you need to define a second Mercury program (ie has a
main, is in a module and everything) that just opens "my.rules" and
reads Mercury data until end. For each data structure it converts,
and then writes to 2nd file. The main procedure will be ten lines or
so. Because you are reading the myrule data type, everything is
automatic.

Then you can very easily for example test the rules for something and
place them in discriminated union cases.

/Tomas


More information about the users mailing list