<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=us-ascii" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ralph Becket schrieb:
<blockquote cite="mid20061008064711.GA18529@ceres.csse.unimelb.edu.au"
 type="cite">
  <pre wrap="">J?rg Roman Rudnick, Saturday,  7 October 2006:</pre>
  <pre wrap="">
The reference manual is quite clear on this one, I thought.  A
declaration of the form

:- instance my_type_class(T) ...

would indicate that all types are instances of my_type_class since T
unifies with anything.
  </pre>
</blockquote>
I am sorry, I was just a little verbose - I agree the manual is quite
good so
far... :-)
<blockquote cite="mid20061008064711.GA18529@ceres.csse.unimelb.edu.au"
 type="cite">
  <pre wrap=""><!---->
The current rules are as generous as we know how to enforce them.  One
of the problems with your request is how to handle cases where an
instance declaration in another module declares

:- instance fringe(list(T), ...) ...

How should the compiler reconcile this with a declaration

:- instance fringe(list(container(T)), ...) ...?

  </pre>
</blockquote>
Aha... :-)<br>
<blockquote cite="mid20061008064711.GA18529@ceres.csse.unimelb.edu.au"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">but I hope there are ways to 
write such an instance declaration like

:-instance fringe(list(T_1), container(T2)) ... ?? ...,

so that, maybe by setting a type class for T_1, a T_1 can be handled as 
a container(T_2).

Has anybody any idea how to realize that?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Can you solve your problem using functional dependencies?
  </pre>
</blockquote>
The short answer: At the moment, no. <br>
<br>
The longer answer:<br>
<br>
The straightforward way,<br>
<br>
<pre wrap="">   :-instance fringe(list(T1), container(T2)) <= (T1 -> T2) where [ ... ]

leads to:
</pre>
    Error: constraints on instance declarations may only constrain type
variables and ground types: _1 -> _2.<br>
<br>
<br>
Another idea is delegating the dependency to a second type class, e.g.,<br>
<br>
        <tt>:-typeclass dependingOn(D1, D2) <= (D1 -> D1) where
[].<br>
</tt>        <tt>:-instance dependingOn(string, string) where [].<br>
    </tt><br>
<pre wrap="">    :-instance fringe(list(T1), container(T2)) <= dependingOn(T1,T2) where [ ... ]</pre>
leading to:<br>
            functional dependency not satisfied: type variable T2
occurs in<br>
            the range of the functional dependency, but is not in the<br>
            domain.<br>
<br>
<br>
Some further experimentation didn't lead to notable enlightenment.<br>
<br>
Although looking somewhat strange, application of containers is a
compromise not too painful for most things, bat: May I stay optimistic??<br>
<br>
<br>
All the best + a nice weekend,<br>
<br>
             Nick
</body>
</html>