[mercury-users] Sneaky pseudo-buglet with typeclasses.
Ralph Becket
rbeck at microsoft.com
Tue Nov 2 05:33:27 AEDT 1999
When I try to compile the following
:- module singlearg.
:- interface.
:- typeclass foo(T) where [
pred new(T),
mode new(out) is det
].
:- implementation.
:- type bar ---> bar(string).
:- instance foo(bar) where [
pred (new/1) is bar_new
].
bar_new(bar("Hi!")).
I get...
singlearg.m:015: Error: expected `pred(<Name> / <Arity>) is <InstanceName>':
pre
d new / 1 is bar_new.
singlearg.m:018: Error: clause for predicate `singlearg:bar_new/1'
singlearg.m:018: without preceding `pred' declaration.
singlearg.m:018: Inferred :- pred bar_new((singlearg:bar)).
singlearg.m:018: Error: no mode declaration for predicate
`singlearg:bar_new/1'.
For more information, try recompiling with `-E'.
The cause of this hard-to-spot error is that I've accidentally inserted a
space between `pred' and the `(new/1)' in the instance declaration. This
is quite a nasty one because the norm in the rest of the language is for
`pred' and `func' to stand as prefix operators - you have to get rid of the
space here or the structure parses differently and the compiler gets upset.
Beware.
To the developers: should I report this as an unclear error message? It's
just taken me 40mins to track down and I hate this sort of 1-char bug.
Cheers,
Ralph
--------------------------------------------------------------------------
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