Contents
Sub modules
| Extensions |
| Operators |
Lazily acquires a value and caches it for repeated use.
Properties
Makes K〈F, A〉 lazy
This is more of a utility type right now, so it hasn't been fleshed out like other Applicatives
Properties
Methods
method Memo<G, A> transform <F, G, A> (Memo<F, A> ma) Source #
Natural transformation for memoised higher-kinded structures
Parameters
| type | F | Original structure |
| type | G | New structure |
| type | A | Bound value type |
| param | ma | Structure to transform |
| returns | Naturally transformed structure | |
method Memo<F, A> cotransform <F, G, A> (Memo<G, A> ma) Source #
Natural transformation for memoised higher-kinded structures
Parameters
| type | F | New structure |
| type | G | Original structure |
| type | A | Bound value type |
| param | ma | Structure to transform |
| returns | Naturally transformed structure | |
Methods
method Memo<A> memo <A> (Func<A> f) Source #
Returns a Memo〈A〉 that wraps a function. The first
call to the resulting Memo〈A〉 will cache the result.
Subsequent calls return the cached item.
method Memo<F, A> memoK <F, A> (Func<K<F, A>> f) Source #
Returns a Memo〈F, A〉 that wraps a function that yields a higher-kind K〈F, A〉.
The first call to the resulting Memo〈F, A〉 will cache the resulting K〈F, A〉.
Subsequent calls return the cached item.
NOTE: This does not invoke the K〈F, A〉 computation, it merely caches the construction
of the K〈F, A〉. If K〈F, A〉 itself is lazy, then it can be invoked multiple times;
this memoisation won't affect that.
method Memo<F, A> memoK <F, A> (A value) Source #
Create a preloaded memo structure with a pure value
method Memo<F, A> memoK <F, A> (K<F, A> fa) Source #
Create a preloaded memo structure.
method Func<A, B> memo <A, B> (Func<A, B> func) Source #
Returns a Func〈A, B〉 that wraps func. Each time the resulting
Func〈A, B〉 is called with a new value, its result is memoized (cached).
Subsequent calls use the memoized value.
Remarks: Thread-safe and memory-leak safe.
method Func<T, R> memoUnsafe <T, R> (Func<T, R> func) Source #
Returns a Func〈T, R〉 that wraps func. Each time the resulting Func〈T, R〉 is called with a new value, its result is memoized (cached). Subsequent calls use the memoized value.
Remarks: No mechanism for freeing cached values and therefore can cause a memory leak when holding onto the Func〈T, R〉 reference. Uses a ConcurrentDictionary for the cache and is thread-safe
method Seq<T> memo <T> (IEnumerable<T> seq) Source #
Enumerable memoization. As an enumerable is enumerated each item is retained in an internal list, so that future evalation of the enumerable isn't done. Only items not seen before are evaluated.
This minimises one of the major problems with the IEnumerable / yield return pattern by causing at-most-once evaluation of each item.
Use the IEnumerable extension method Memo for convenience.
Although this allows efficient lazy evaluation, it does come at a memory cost. Each item is cached internally, so this method doesn't allow for evaluation of infinite sequences.
Parameters
| param | seq | Enumerable to memoize |
| returns | IEnumerable with caching properties | |