[mercury-users] Appreciate some help #4:

Tyson Dowd trd at stimpy.cs.mu.oz.au
Tue May 26 15:33:33 AEST 1998


On 25-May-1998, tcklnbrg <at at ingenuity-sw.com> wrote:
> % test.m----Please look at this example and tell me if I understand it. 
> Thanks very much.
 
Just wanted to show you about a formatting convention that works well
for Mercury.  I'll reformat some of your code in it to demonstrate.

%------------

:- module test.
:- interface.
:- 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.
 
 
:- implementation.
 
validateClassname(S) :-
	string__is_alpha(S).

	% the actual javaclass clause would be read in at runtime.
javaclass(C).

main -->
	( { javaclass(validateClassname("123")) } ->
		io__write_string("OK\n\n")
	;
		io__write_string("Failed\n\n")
	).

-- 
       Tyson Dowd           # So I asked Sarah: what's the serial number on
                            # your computer? She replied:
     trd at cs.mu.oz.au        #          A-C-2-4-0-V-/-5-0-H-Z
http://www.cs.mu.oz.au/~trd #



More information about the users mailing list