Appreciate some help #4:
at at ingenuity-sw.com
Tue May 26 12:15:25 AEST 1998
% test.m----Please look at this example and tell me if I understand it.
:- module test.
:- import_module io, string.
:- type classname ---> validateClassname(string).
:- pred validateClassname(string::in) is semidet.
:- pred javaclass(classname::in) is det.
:- pred main(io__state::di, io__state::uo) is det.
% the actual javaclass clause would be read in at runtime.
/* the above prints "OK" implying that the function
is never called --compiler admits main
The module also compiles and runs without any definition for
pred, validateClassname. I have tested, also, that a string which would
fail the "is_alpha" test, including a "", also succeeds.
This would tend to imply, all-around, that any real type
validation can only occur for types defined as built-ins.
Do I get this right? If so, what use is there for a type definition
like type ---> func(type) if func isn't used? Actually, why doesn't
Mercury require defining a pred for func?
As I understand it now, I really cannot do typechecking for types other
than built-ins. Is this correct? Would using typeclasses help? If so,
where is the documentation for typeclasses?
Thanks for any help...continuing to hack along.
More information about the users