On Wed, 2007-05-02 at 20:23 -0400, Chris King wrote:
> When I write this instance (yes I know it's incomplete):
>
> instance[t with Addgrp[t]] Addgrp[t*t] {
> fun zero() => zero[t](), zero[t]();
> }
>
>
> Felix gives this error:
>
> UNRESOLVED RETURN ERROR
> In complex.flx: line 55, cols 2 to 36
> 54: instance[t with Addgrp[t]] Addgrp[t*t] {
> 55: fun zero() => zero[t](), zero[t]();
> ***********************************
> 56: }
>
> [typeofindex'] function zero<5469>: Can't resolve return type, got : <T5469>
> Possibly each returned expression depends on the return type
> Try adding an explicit return type annotation
>
>
> Okay, let's try this:
>
> instance[t with Addgrp[t]] Addgrp[t*t] {
> fun zero(): t*t => zero[t](), zero[t]();
> }
>
>
> Now we get:
>
> CLIENT ERROR
> In return ((zero[t] ()), (zero[t] ()));
> Wrong return type,
> expected : <T5467> * <T5467>
> but we got (<T5467> * <T5467>)^2
> In complex.flx: line 55, cols 2 to 41
> 54: instance[t with Addgrp[t]] Addgrp[t*t] {
> 55: fun zero(): t*t => zero[t](), zero[t]();
> ****************************************
> 56: }
>
>
> This makes no sense... wouldn't the return type be just <T5467> * <T5467>?
>
> Curiously, this compiles:
>
> instance[t with Addgrp[t]] Addgrp[t*t] {
> fun zero(): t => zero[t](), zero[t]();
> }
>
> What's going on here? Am I missing something critical?
It looks like 'zero' is binding to the instance local zero
not the typeclass zero. It shouldn't match. If you actually
run the version that compiles I bet it goes into an infinite loop:
its calling itself.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language