Memoize.mli 2.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
(******************************************************************************)
(*                                                                            *)
(*                                    Fix                                     *)
(*                                                                            *)
(*                       François Pottier, Inria Paris                        *)
(*                                                                            *)
(*  Copyright Inria. All rights reserved. This file is distributed under the  *)
(*  terms of the GNU Library General Public License version 2, with a         *)
(*  special exception on linking, as described in the file LICENSE.           *)
(*                                                                            *)
(******************************************************************************)

POTTIER Francois's avatar
POTTIER Francois committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
open Sigs

(* [Make] constructs a memoizer for a type [key] that is
   equipped with an implementation of imperative maps. *)

module Make
  (M : IMPERATIVE_MAPS)
     : MEMOIZER with type key = M.key

(* [ForOrderedType] is a special case of [Make] where it
   suffices to pass an ordered type [T] as an argument.
   A reference to a persistent map is used to hold the
   memoization table. *)

module ForOrderedType
28
  (T : OrderedType)
POTTIER Francois's avatar
POTTIER Francois committed
29 30 31 32 33 34 35
     : MEMOIZER with type key = T.t

(* [ForHashedType] is a special case of [Make] where it
   suffices to pass a hashed type [T] as an argument. A
   hash table is used to hold the memoization table. *)

module ForHashedType
36
  (T : HashedType)
POTTIER Francois's avatar
POTTIER Francois committed
37 38 39 40 41 42 43 44 45 46 47
     : MEMOIZER with type key = T.t

(* [ForType] is a special case of [Make] where it suffices
   to pass an arbitrary type [T] as an argument. A hash table
   is used to hold the memoization table. OCaml's built-in
   generic equality and hash functions are used. *)

module ForType
  (T : TYPE)
     : MEMOIZER with type key = T.t

48
(* Memoizers for some common types. *)
POTTIER Francois's avatar
POTTIER Francois committed
49

50 51 52
module Char
     : MEMOIZER with type key = char

POTTIER Francois's avatar
POTTIER Francois committed
53 54
module Int
     : MEMOIZER with type key = int
55 56 57

module String
     : MEMOIZER with type key = string