[mercury-users] Functional dependencies bug

Peter Ross pro at missioncriticalit.com
Tue May 16 11:38:14 AEST 2006


Hi,

Uncomment one line in do_something and this program compiles,
or remove the typevariable X from the typeclass definitions and
the program compiles.  Note this comes from a test case where
there are methods which use X in typeclass definitions.

Can someone please confirm this is a bug in the mercury compiler,
or do I misunderstand the interaction of inheritance and 


:- module test1.
:- interface.
:- import_module io.
:- pred main(io.state::di,io.state::uo) is cc_multi.

:- implementation.
:- import_module string.

:- typeclass a(A, X) <= ((A->X), (X->A)) where [
   func hello(A) = string
].

:- typeclass b(B, X) <= (a(B, X), (B->X), (X->B)) where [
   func goodbye(B) = string
].

:- type some_b  ---> some[B, X] some_b(B) => b(B, X).

:- instance a(string, int) where [
   hello(S) = "hello " ++ S
].

:- instance b(string, int) where [
   goodbye(S) = "goodbye " ++ S
].

:- pred do_something(some_b::in, io.state::di,io.state::uo) is det.

do_something(SomeB1, !IO) :-
   SomeB1 = some_b(B1),
   io.write_string(hello(B1), !IO),
   % Uncomment the line below and this compiles.
   % io.write_string(goodbye(B1), !IO),
   true.


main(!IO)  :-
   SomeB1 = 'new some_b'("test"),
   do_something(SomeB1, !IO).
--------------------------------------------------------------------------
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