[m-users.] Ambiguous overloading error, with_type suggested

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Jun 13 18:51:54 AEST 2021


2021-06-13 18:43 GMT+10:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com>:
> Your response says that the function form takes a function as the first arg but they all take a closure as the first argument, at least from looking  at the source code for 20.06.01.

You are right, I was wrong: all versions of list.filter take a pred as the first arg.
The ambiguity comes in because list.filter has both an arity 3 and an arity 4 version,
and the compiler does not know which one you are trying to partially apply.

Normally, the ambiguity is resolved when you use the result of the partial application
in a context that matches only one of the alternatives. However, in your original code,
the *only* thing you did with Tokens was convert it to a string, using string.string,
and that can be done for *any* type. That was what the original ambiguity message
was about. (I should not have sent my first reply before by first morning dose
of caffeine :-)

> If I understand your response correctly, you are saying that Tokens is in fact bound to a closure presumably because I have failed to fully satisfy a func/pred form and ended up with, in Haskell terminology, a partial application?

Yes.

> Changing my code to read:
> 
> 	list.filter(Pr. Tk, Tokens)
> 
> compiles as the first predicate form was satisfied, changing it to this:
> 
>     list.filter(Pr, Tk, Tokens, Comments),
> 
> also compiles as the second predicate form is used (this might be useful in the future actually :) and this code:
> 
>     Tokens = list.filter(Pr, Tk)
> 
> obviously still fails to compile and I still fail to understand. 

I hope the above explains it.

Zoltan.


More information about the users mailing list