[mercury-users] literature polymorphic recursive calls

Peter Stuckey pjs at cs.mu.OZ.AU
Thu Jun 23 12:59:19 AEST 2005


>>
>> p(X,Y) :- (X == Y -> p(true,false) ; p(1,2))
>>
>
> I don't know very much about the type inference problem being 
> discussed in this thread, but the Mercury compiler infers the types of 
> the above just fine (well a slightly modified version of the above, 
> since the above isn't correct Mercury syntax).
>
>
> :- module peter.
>
> :- interface.
>
> :- import_module io.
>
> :- pred main(io::di, io::uo) is det.
>
> :- implementation.
>
> :- import_module bool, int, float.
>
> main(!IO) :-
>         ( if p(1.0, 2.0) then
>                 io.write_string("yes", !IO)
>         else
>                 io.write_string("no", !IO)
>         ),
>         nl(!IO).
>
> % :- pred p(X::in, X::in) is semidet.
> :- mode p(in, in) is semidet.
>
> p(X, Y) :- (X = Y -> p(yes, no) ; p(1, 2)).
>
>
> $ mmc peter --infer-all
> peter.m:022: Inferred :- pred p(T2, T2).

I stand corrected.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Peter Stuckey.vcf
Type: text/directory
Size: 524 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20050623/5e904e8d/attachment.bin>
-------------- next part --------------



More information about the users mailing list