Reputation: 530
I am trying to use Mercury to create a small library of grammar constructs. Now, I'd like to have some higher-order "rules". I'd like the arguments to those rules to have free variables, so I can write something like:
parenthesised(day_of_week(X), In, Out)
and if the code is run against for example '(tuesday)' it succeeds and X ends up bound to 2. Mercury refuses such program with the following error message:
mode error: variable `X' has instantiatedness `free', ho.m:034: expected instantiatedness for non-local variables of lambda goals ho.m:034: is `ground'.
Now, I understand Mercury is not Prolog and there are limitations on what can be free and when etc. The question is: how do I express this kind of abstraction in Mercury? Macros come to mind, but those are, unfortunately, also not available in Mercury.
Upvotes: 2
Views: 51