[m-dev.] for review: allow impurity on class methods
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Mar 27 16:18:45 AEST 2000
On 27-Mar-2000, David Glen JEFFERY <dgj at ender.cs.mu.oz.au> wrote:
> :- module impure_method_impl.
> :- interface.
>
> :- import_module io.
>
> :- pred main(io__state::di, io__state::uo) is det.
>
> :- typeclass c(T) where [
> pred m1(T::in, int::out) is det,
> semipure pred m2(T::in, int::out) is det
> ].
>
> :- type foo ---> foo.
>
> :- instance c(foo) where [
> pred(m1/2) is foo_m1, % line 16
> pred(m2/2) is foo_m2 % line 17
> ].
>
> :- semipure pred foo_m1(foo::in, int::out) is det.
> :- impure pred foo_m2(foo::in, int::out) is det.
...
> impure_method_impl.m:017: In call to impure predicate `impure_method_impl:foo_m2/2':
> impure_method_impl.m:017: error: call must be preceded by `impure' indicator.
> impure_method_impl.m:017: In type class method implementation:
> impure_method_impl.m:017: error: predicate is impure.
> impure_method_impl.m:017: It must be declared `impure' or promised pure.
> impure_method_impl.m:016: In call to semipure predicate `impure_method_impl:foo_m1/2':
> impure_method_impl.m:016: error: call must be preceded by `semipure' indicator.
> impure_method_impl.m:016: In type class method implementation:
> impure_method_impl.m:016: error: predicate is semipure.
> impure_method_impl.m:016: It must be declared `semipure' or promised pure.
There's two things about that error message which could be improved.
First, the error messages about "call must be preceded by `impure' indicator"
are bogus; there is no explicit call anywhere in the source code,
and there is no place in the syntax to insert an `impure' indicator'.
The compiler should not report such errors in typeclass instance methods.
Second, the error messages are in reverse order. It would be nicer
if the compiler processed class methods in the order that they were declared,
rather than in reverse order.
--
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-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