[mercury-users] [petdr at miscrit.be: Report on the ICFP 2000 prog contest]

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Sep 7 16:38:56 AEDT 2000


On 07-Sep-2000, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> 
> While you're at it, how about also allowing people to omit 'is' clauses from
> an instance declaration for any predicate or function that is already
> defined with the right signature?  This would save you from writing things
> in two places by letting you write just the predicate/function.  I expect
> this will tend to come up quite often (it even does in the reference manual
> discussion of type classes).
> 
> For example, if I have a class fooable:
> 
>         :- typeclass fooable(T) where [
>                 pred foo(T, int),
>                 mode foo(in, out) is det
>         ]
> 
> and I have a type sometype with a foo/2 predicate:
> 
>         :- type sometype ---> ...
> 
>         :- pred foo(sometype, int).
>         :- mode foo(in, out) is det.
>         ...
> 
> then it seems kind of silly to have to say
> 
>         :- instance fooable(sometype) where [
>                 foo/2 is foo
>         ].

Well, I wouldn't write it like that; I'd use an explicit module
qualifier or two.  For example, if the `fooable' type class is
defined in module `tc', and the implementation of `foo' is defined
in module `impl', I might write it like so:

         :- instance tc__fooable(sometype) where [
                 tc__foo/2 is impl__foo
         ].

In an appropriate programming environment, even if you wrote it as
`foo/2 is foo', the IDE or editor may be able to display which symbol
each `foo' resolves to when you move the cursor over it, so even then
it could be useful in helping readers understand the program.

We should keep this suggestion in mind in future, but currently my
opinion is that there is no great need for it, and that it might
potentially harm readability.  If cases like this really do crop up
very often in practice, then we can reconsider this in future.

Cheers,
	Fergus.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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