Source

planck / smemo.mli

Full commit
type 'key memo
val create : int -> 'key memo

(** Extend(Base) extends Base with memoization over each stream element.
    Typical usage is:

    module MyStream = struct
      module Base = ... (* creation of Base *)
      include Base
      include Smemo.Extend(Base)
    end
*)

module Extend(Base : sig
  include Stream_intf.S
  type key (* CR jfuruse: if we can get the source position by p4 or something, it is a good automatic value for key *)
  val memo : t -> key memo
  (** memo cache can be obtained from t *)
end) : sig
  open Base
  type key = Base.key
  val memoize : key -> (t -> 'a) -> t -> 'a
end