[mercury-users] 'Char' type problem
Andrew Bromage
bromage at cs.mu.OZ.AU
Tue Mar 17 22:50:24 AEDT 1998
G'day all.
On 17-Mar-1998, Peter Phelan <peter.phelan at anite-systems.lu> wrote:
> > I have a very simple program, which produces the following
> > error under mmc --
> > error: undefined type char/1.
> >
> > I understood that char was a built in recognised type.
Fergus Henderson wrote:
[Detail omitted]
> So, you just need to add `:- import_module char'.
As Fergus said, except that char/1 isn't declared in the library, but
char/0 is.
Your program should read:
<<
:- module foo1.
:- import_module char.
:- pred foo1(char, char).
:- mode foo1(in, out) is semidet.
foo1(A, B):-
A = B.
>>
For the builtin types (int, float, char, string), the compiler doesn't
complain if you import the corresponding module but don't use it. It's
therefore not a bad idea to do it anyway.
The library should be fixed to either allow char without a module
import, or require int/float/string to have its module imported too,
since this is a non-orthogonality.
Cheers,
Andrew Bromage
More information about the users
mailing list