Hi Sebastien, Sebastien Carlier wrote:
I am getting an error message from ghc 4.08.1 with the following code:
class Collection e ce | ce -> e where empty :: ce insert :: e -> ce -> ce
class (Eq e, Collection e ce) => Set e ce where member :: e -> ce -> Bool union :: ce -> ce -> ce
Main.lhs:7: Class type variable `e' does not appear in method signature union :: {- implicit forall -} ce -> ce -> ce
Since `ce' uniquely determines `e', I would expect the compiler to assume that `e' appears in the method signature. Either I am misunderstanding something, or something may be missing in the compiler around rename/RnSource.lhs:249.
I encountered the same problem this summer and wrote to Simon PJ and Jeff Lewis. Here's Jeff's answer:
I'm glad to find examples where they are indispensible. The implementation of FDs in GHC is pretty much complete WRT Mark's writeup (but it doesn't complain about instances inconsistent with FDs). I'm using them in a current project, but in a fairly conservative manner. In hugs, I implemented several extensions to do with derived instances and superclasses - pretty much necessary as you've found. Unfortunately, in hugs I implemented it in rather the wrong way. Based on dicsussions at the Hugs/GHC meeting w/ Simon, I have a cunning plan for finishing the implementation properly in GHC, but just haven't had the chance to do it. What I need to do is write it up, so that either Simon or myself can finish the job.
So the short answer to your question is: FD in derived instances is not implemented in GHC yet. I'm still eagerly waiting to use this feature in my project. Jeff, could you give us an update on the progress? Thanks! -- # Zhanyong Wan http://pantheon.yale.edu/~zw23/ ____ # Yale University, Dept of Computer Science /\___\ # P.O.Box 208285, New Haven, CT 06520-8285 ||___|