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

Volker Wysk post at volker-wysk.de
Wed Jan 19 19:54:00 AEDT 2022


Hello Julien

Thanks for your answer. I need to read more about insts.

Cheers, Volker


Am Mittwoch, dem 19.01.2022 um 19:18 +1100 schrieb Julien Fischer:
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20220119/ad65487a/attachment.sig>


More information about the users mailing list