package memo

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module type S = sig ... end

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

val get_initial_cache_size : unit -> int

Functions on the initial size used when creating a cache, you can change get the current value, update it to a number of your choice, or reset it to the default value.

val set_initial_cache_size : int -> unit

Functions on the initial size used when creating a cache, you can change get the current value, update it to a number of your choice, or reset it to the default value.

val reset_initial_cache_size : unit -> unit

Functions on the initial size used when creating a cache, you can change get the current value, update it to a number of your choice, or reset it to the default value.

val mk_memo : (int -> 'a) -> ('a -> 'b -> 'c) -> ('a -> 'b -> 'c -> 'd) -> (('b -> 'c) -> 'b -> 'c) -> 'b -> 'c

mk_memo create find add ff gives a memoïzed version of the functional ff using the functions create, find and add for the cache. It's used internally and you shouldn't have to use it.

module Mk (Cache : 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 MakeWeak (H : 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 Make (H : 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 Fake (H : 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.

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

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