[mercury-users] inst decls and fixed-length lists

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Thu Feb 23 16:01:46 AEDT 2006


Dear Ralph, thank you for responding so quickly.  You wrote.

>[is there any way you could stick to 78 columns?  Your e-mail gets badly
>mangled by line wrapping.]

Ook!  So sorry!  I'll hand-terminate lines from now on.

>> but trying to use the composed insts gets me compiler errors:
>> Fore = [purple, crimson, cyan, amber],
>> print_foursome(Fore)
>> :- pred print_foursome(list(T)::in(four_gone(T, []), io::di, io::uo) is det.
>> print_foursome(TrueColours) --> print(TrueColours), nl.
>
>Hmm.  Well, one problem is that you're using T as a type variable
>and as an inst variable here.  Inst polymorphism is something that is
>not well tested and is known to be buggy.  You should be able to fix
>things like this:
>
>:- pred print_foursome(list(T)::in(four_gone(ground, []), io::di, io::uo)
>        is det.
>print_foursome(TrueColours) --> print(TrueColours), nl.

How simple, effective, and, on reflection, how obvious!  Yes, this fix
solved my problem.  Thank you for the help.

Sincerely,
Doug Auclair

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list