[m-users.] How to abbreviate a higher order mode?
Julien Fischer
jfischer at opturion.com
Thu Apr 2 01:03:49 AEDT 2026
Hi,
On Thu, 2 Apr 2026 at 00:43, Volker Wysk <post at volker-wysk.de> wrote:
>
> Hi!
>
> I have higher-order arguments with lengthy types and modes, such as:
>
> pred(fis_args, list(string), master_loop_data, master_loop_data, io, io)
> ::in(pred(in, in, in, out, di, uo) is cc_multi),
>
> Now I want to abbreviate it, so it becomes something like this:
>
> master_prepare::in(master_prepare),
>
> I've tried this:
>
> :- type master_prepare ==
> pred(fis_args, list(string), master_loop_data,
> master_loop_data, io, io).
>
> :- inst master_prepare == pred(in, in, in, out, di, uo).
>
> The inst doesn't work - the right side is a mode, not an inst. This doesn't
> work either:
That doesn't work for two reasons:
1. The RHS is not a mode nor an inst. A higher-order inst needs to
both describe the modes
of the arguments *and* the determinism (i.e. you've left out "is cc_multi").
2. The second reason is that due to the relative precedence of the
"==" and "is" operators
you need to enclose the RHS in parenthesis.
It should be:
:- inst master_prepare == (pred(in, in, in, out, di, uo) is cc_multi).
(See the "Higher-order insts and modes" section of the reference manual.)
Julien.
More information about the users
mailing list