[m-dev.] Re: For review: changes to graph.m
Peter Schachte
pets at cs.mu.oz.au
Thu Jun 5 10:48:21 AEST 1997
On Wed, 4 Jun 1997, Fergus Henderson wrote:
> I think you can have code such as
>
> let
> map0 = map_init
> map1 = map_insert map0 "foo" 42
> in
> ..
>
> and I think then Gofer's type inference will figure out which instance
> declaration to use based on which type-classes String is an instance
> of.
This is exactly what I had in mind.
> If String has both Hash and Ord, and neither is a subclass of the other,
> and there is no instance declaration requiring both Hash and Ord,
> then I think it is ambiguous, and you have to resolve the ambiguity
> with an explicit type declaration, or by providing an instance
> declaration that is more specific than both.
This is where some centralized preference list would be helpful. Assuming
that each type is implemented in a separate file, and assuming that the
user isn't going to explicitly list all of these files in his import list,
there will have to be some centralized list somewhere; this list can
express a preference order.
> This main problem with overlapping instance declarations is that
> they basically prevent separate compilation.
Would they in Mercury, where a module has to declare types and modes for
its exports? I would expect between a file and the interfaces of its
imports you'd have everything you need to choose a type.
-Peter Schachte URL: http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU PGP: finger pets at 128.250.37.150 for key
[A computer is] like an Old Testament god, with a lot of rules
and no mercy. -- Joseph Campbell
More information about the developers
mailing list