[m-users.] Ambiguous overloading error, with_type suggested
Zoltan Somogyi
zoltan.somogyi at runbox.com
Sat Jun 12 18:56:40 AEST 2021
2021-06-12 18:50 GMT+10:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com>:
> The error:
> ast.m:042: In clause for predicate `on_lexer'/1:
> ast.m:042: error: ambiguous overloading causes type ambiguity.
> ast.m:042: Possible type assignments include:
> ast.m:042: Tokens: `pred(list.list(lexer.token), list.list(lexer.token))' or
> ast.m:042: `(pred list.list(lexer.token))'
> ast.m:042: You will need to add an explicit type qualification to resolve the
> ast.m:042: type ambiguity. The way to add an explicit type qualification is
> ast.m:042: to use "with_type". For details see the
> ast.m:042: "Explicit type qualification" sub-section of the "Data-terms"
> ast.m:042: section of the "Syntax" chapter of the Mercury language reference
> ast.m:042: manual.
>
> the ast.m code:
>
> [42]on_lexer(Lx) :-
> Tokens = list.filter(
> % is_comment,
> (pred(T::in) is semidet :- Ty = tok_type(T), not (Ty = c1 ; Ty = cn)),
> tokens(Lx)
> ),
list.filter exists both as a predicate and as a function. The predicate form
takes a predicate as first arg, while the function form takes a function.
The first error is mixing up these two. This unification does not bind Tokens
to a list of tokens; it binds it to a closure.
Zoltan.
More information about the users
mailing list