#
# This is a simple cache enum.
#
# -- Allen Leung
# Compiled by:
#
src/lib/compiler/back/low/lib/lib.libapi Cache_Ref {
Cache(X);
cache: (X -> Y) -> X -> Cache(Y);
flush: Cache(X) -> Void;
(!_) : Cache(X) -> X;
:= : (Cache(X), X) -> Void;
};
package cache_ref: Cache_Ref { # Cache_Ref is from
src/lib/compiler/back/low/library/cache.pkg Cache(X)
=
(Ref( Null_Or(X) ), (Void -> X));
fun cache f x
=
( REF NULL,
\\ _ = f x
);
fun flush (x, _)
=
x := NULL;
fun !(r as REF NULL, f) => { x = f(); r := THE x; x; };
!(r as REF (THE x), f) => x;
end;
my (:=)
=
\\ ((r, _), x)
=
r := THE x;
};