:- module try_goal_opt. :- interface. :- import_module io. :- pred bad_try(pred(T, io, io), T, io, io). :- mode bad_try(pred(out, di, uo) is det, out, di, uo) is cc_multi. :- implementation. :- import_module exception. bad_try(Pred, Result, !IO) :- ( try [io(!IO)] Pred(Result0, !IO) then Result = Result0 catch_any Excp -> % do stuff throw(Excp) ).