:- module daytype. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. :- import_module string, list. :- type days ---> sunday ; monday ; tuesday ; wednesday ; thursday ; friday ; saturday. :- func daytype(days) = string. daytype(D) = R :- ( (D = sunday ; D = saturday), R = "weekend" ; (D = monday ; D = tuesday ; D = thursday ; D = friday), R = "workday" ; D = wednesday, R = "humpday" ). main(!IO) :- io.command_line_arguments(Args, !IO), ( if Args = [DayString], Lowered = to_lower(DayString), Term = Lowered ++ ".", io.read_from_string("args", Term, length(Term), ok(Day), io.posn(0, 0, 0), _) then io.format("daytype(%s) = ""%s"".\n", [s(Lowered), s(daytype(Day))], !IO) else io.progname_base("daytype", Program, !IO), io.format(io.stderr_stream, "usage: %s <weekday>\n", [s(Program)], !IO), io.set_exit_status(1, !IO) ).