:- module main.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module nat.
:- pred print_parity(nat::in, io::di, io::uo) is det.
print_parity(N, !IO) :-
io.write_string(if even(N) then "even\n" else "odd\n", !IO).
:- pred example(nat::in, io::di, io::uo) is det.
example(z, !IO).
example(s(N), !IO) :-
print_parity(N, !IO),
example(N, !IO).
main(!IO) :-
example(s(s(s(s(s(s(s(z))))))), !IO).
:- module nat.
:- interface.
:- type nat ---> z ; s(nat).
:- pred even(nat).
:- mode even(in) is semidet.
:- implementation.
even(z).
even(s(s(N))) :- even(N).