<div>Hi,</div><div><br></div>Why line XXX compiles well, but not YYY? I thought that types aaa & bbb are quite similar...<div><br></div><div><div>:- module t1.</div><div>:- interface.</div><div>:- import_module io.</div>
<div>:- pred main(io::di, io::uo) is det.</div><div><br></div><div>:- implementation.</div><div><br></div><div><br></div><div>:- typeclass qqqable(T) where [</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>func qqq(T) = T</div>
<div>].</div><div><br></div><div>:- type aaa ---> aaa(int).</div><div><br></div><div>:- type bbb(T) ---> bbb(T).</div><div>:- type bbb == bbb(int).</div><div><br></div><div>:- instance qqqable(aaa) where [ func(qqq/1) is qqq_aaa ]. % XXX</div>
<div>:- instance qqqable(bbb) where [ func(qqq/1) is qqq_aaa ]. % YYY</div><div><br></div><div>qqq_aaa(A) = A.</div><div><br></div><div>main(!IO) :- print(qqq(aaa(7)),!IO).</div></div><div><br></div><div>The compilation shows:</div>
<div><br></div><div><div>D:\stuff\test\mercury\solver>..\mmc_.bat t1 -E</div><div>Making Mercury\int3s\t1.int3</div><div>Making Mercury\ints\<a href="http://t1.int">t1.int</a></div><div>Making Mercury\cs\t1.c</div><div>
t1.m:019: In instance declaration for `t1.qqqable(t1.bbb(int))':</div><div>t1.m:019:   the first arg is a type whose first arg is not a variable</div><div>t1.m:019:   types in instance declarations must be functors with distinct</div>
<div>t1.m:019:   variables as arguments</div><div>Error: system command received signal 1.</div><div>** Error making `Mercury\cs\t1.c'.</div></div><div><br></div><div>Could someone clarify why couldn't this work?</div>
<div><br></div><div>Sincerely yours,</div><div>Vladimir</div>