Module Memo

Tuning

val get_initial_cache_size : unit -> int

Get the value used as an initial size when creating a cache.

val set_initial_cache_size : int -> unit

Set the value used as an initial size when creating a cache.

val reset_initial_cache_size : unit -> unit

Reset to default the value used as an initial size when creating a cache.

Generic interface

val memo : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b

memo ff gives you a memoïzed version of the ff functional.

Functorial interface

module type S = sig ... end

The output signature of the functors Mk, Make, MakeWeak and Fake.

module Mk : functor (Cache : Stdlib.Hashtbl.S) -> sig ... end

With the Mk functor, you can also directly provide a Cache module, which should have the signature Hashtbl.S. We will include your cache module and use it to define a memo function. It should be useful only if you want to use another Hashtbl implementation or things like this.

module Make : functor (H : Stdlib.Hashtbl.HashedType) -> sig ... end

Functor that can be useful in case you don't want to use polymorphic equality or you are doing things like hashconsing and you know how to compare or hash your type more efficiently.

module MakeWeak : functor (H : Stdlib.Hashtbl.HashedType) -> sig ... end

Functor that works like the Make one, but the bindings in the memoïzation cache will be weak, allowing the garbage collector to remove them if they are not used somewhere else.

module Fake : functor (H : Stdlib.Hashtbl.HashedType) -> sig ... end

Functor that is useful if you want to quickly test a function you memoïzed with our Make or MakeWeak functor, but without memoïzing it. It'll basically do nothing and should be equivalent to your initial non-memoïzed function.