[m-dev.] Foreign type compare and unification

Peter Ross pro at missioncriticalit.com
Tue May 14 19:32:04 AEST 2002


fjh wrote:
> On 12-May-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > Is there any reason why we have user-defined equality but not
> > user-defined comparison?  Not having user-defined comparison
> > makes it difficult to use data types such as cords (strings
> > represented as trees for constant-time append).
>
> One reason is that although it makes sense to special-case equality
> in a logic programming language, the argument for special-casing
> comparison is much weaker.
>
> User-defined comparison is still not a complete solution to the problem.
> You also need user-defined io__print, for example.
> It would be nicer to devise a solution that doesn't single out
> comparison, but would work equally well for hashing, printing, etc.
>
IMHO the typeclass approach with the deriving annotation from Haskell seems
the most elegant approach to me.  It also ensures that before you can use a
type it is printable/hashable/comparable and so on.  Yes it would cause
backwards compatibility problems, but it would also make integration with
types implemented in a foreign language a lot more elegant.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list