:- module fib. :- interface. :- func checked_fib(int) = int. :- implementation. :- import_module int. :- import_module io. % not used in opt-exported defns :- import_module map. % not used :- pragma inline(checked_fib/1). checked_fib(N) = F :- ( if N >= 40 then F = -1 else F = fib(N) ). :- func fib(int) = int. fib(N) = F :- trace [io(!IO)] ( %io.print_line({"N", N}, !IO) io.write({"N", N}, !IO) ), ( if N < 2 then F = 1 else F = fib(N - 1) + fib(N - 2) ).