[m-users.] "this is not allowed in a type constructor's argument"

Julien Fischer jfischer at opturion.com
Wed Jan 19 19:18:55 AEDT 2022


Hi Volker,

On Wed, 19 Jan 2022, Volker Wysk wrote:

> When I do this:
>
> :- func actions = assoc_list(string,
>                             (pred(string::in, string::out) is det)).

You cannot use combined predmodes like
"pred(string::in, string::out) is det" in a function type delcaration
like that.

> I get this:
>
> test2.m:009: In `:- func' declaration:
> test2.m:009:   in the return value
> test2.m:009:   error: the type `(pred((string :: in), (string :: out)) is
> det)'
> test2.m:009:   contains higher order inst information, but this is not
> allowed
> test2.m:009:   in a type constructor's argument.
>
> Why doesn't this work? How should it be done ...?

Either, with a separate mode declaration:

    :- func actions = assoc_list(string, (pred(string, string))).
    :- mode actions = out(list(pair(ground, (pred(in, out) is det)))) is det.

or with a predmode declaration:

     :- func actions =
       (assoc_list(string, (pred(string, string)))::out(list(pair(ground, (pred(in, out) is det))))) is det.

Note the standard library does not define this inst:

     :- inst assoc_list(K, V) == list(pair(K, V)).

I've had to resort to writing out the expansion, e.g.
list(pair(ground, ...)), instead.

Julien.


More information about the users mailing list