:- module lazy.
:- use_module builtin, mutvar, private_builtin.
:- type lazy.lazy_state(T)
	--->	value(T)
	;	closure(((func) = T)).
:- type lazy.lazy(T)
	--->	lazy(mutvar.mutvar(lazy.lazy_state(T)))
	where	equality is (lazy.equal_values),
		comparison is (lazy.compare_values).
lazy.equal_values(X_3, Y_4) :-
    V_5 = lazy.force(X_3),
    V_5 = lazy.force(Y_4).
lazy.compare_values(R_4, X_5, Y_6) :-
    V_7 = lazy.force(X_5),
    V_8 = lazy.force(Y_6),
    builtin.compare(R_4, V_7, V_8).
:- pragma exceptions(function, (lazy.val), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (lazy.delay), 2, 0, may_throw(user_exception)).
:- pragma exceptions(function, (lazy.force), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (lazy.read_if_val), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (lazy.equal_values), 2, 0, may_throw(user_exception)).
:- pragma exceptions(predicate, (lazy.compare_values), 3, 0, may_throw(user_exception)).
:- pragma termination_info(lazy.val((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(lazy.delay((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(lazy.force((builtin.in)) = (builtin.out), infinite, can_loop).
:- pragma termination_info(lazy.read_if_val((builtin.in), (builtin.out)), infinite, can_loop).
:- pragma termination_info(lazy.equal_values((builtin.in), (builtin.in)), finite(0, [no, no, no]), can_loop).
:- pragma termination_info(lazy.compare_values((builtin.uo), (builtin.in), (builtin.in)), finite(0, [no, no, no, no]), can_loop).
