12345678910111213141516171819202122232425262728293031323334353637383940414243444546open!Coreopen!ImportmoduletypeS=sigtype'adeferred(** Memoization functions like in [Core.Memo], with re-raising of exceptions
thrown asynchronously.
Also see [Lazy_deferred], of which [Deferred.Memo.unit] is a special case. *)(** [general hashable f] returns a memoized version of [f], where the results are stored
in a hash table indexed according to [hashable]. If [f a] asynchronously raises, then
the error is stored in the hash table and is reraised when [a] is demanded.
Unlike [Core.Memo.general], this [general] does not support
[cache_size_bound] due to complexities of asynchrony -- even when one has a deferred
return by the memoized function, there still may be asynchronous jobs working to
determine it.
Unlike [Core.Memo.general], this [general] takes a required [Hashable]
module argument, to avoid unintentional use of polymorphic comparison. *)valgeneral:(moduleHashable.S_plainwithtypet='a)->('a->'bdeferred)->('a->'bdeferred)Staged.t(** Memoize a recursive asynchronous function. See [Memo.recursive] for the introduction.
We do not implement Async-aware dependency cycle detection, so if recursion is not
well-founded then the computation will just deadlock. *)valrecursive:(moduleHashable.S_plainwithtypet='a)->(('a->'bdeferred)->'a->'bdeferred)->('a->'bdeferred)Staged.tvalunit:(unit->'adeferred)->(unit->'adeferred)Staged.tendmoduletypeDeferred_memo=sigmoduletypeS=SmoduleMake(M:Monad.Infixwithtype'at='aDeferred1.t):Swithtype'adeferred:='aM.tincludeSwithtype'adeferred:='aDeferred1.tend