[mercury-users] type-equivalence for DUs

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Thu Mar 16 07:50:09 AEDT 2006


I wish to define my own equality for a simple DU:

:- type espresso ---> single(float); duo(float, float)
        where equality is coffee_goodness.

The compiler complains at my "ignore args" equality:

:- pred coffee_goodness(espresso::in, espresso:in) is semidet.
coffee_goodness(single(_), single(_)).
coffee_goodness(duo(_, _), duo(_, _)).

Saying that unification may fail.  I thought that's what
'semidet' meant.  Any rewrite of the above that I've
tried leads to the same error, e.g.:

coffee_goodness(A, B) :-
  A = single(_) -> B = single(_); B = duo(_, _).

The refman documentation isn't helping me any more ... what
am I doing incorrectly?

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