Hi, I'm building a generic stream processing framework that makes use of many generic types composed together. As part of the framework, I have factory types that memoize these composite types and returns a reference to them.
I'm asking for strategies to help create these factory types such that the complexity of the types get erased. So far, I've done it via a factory type like the below:
What I do is attach a closure and set the factory as the closure. Then I will create declarative macros to wrap these factories along with the closure. This has worked well to remove the extent of the type that is being stored in the cache, but I also may want to extend to support a factory that can output multiple types rather than a single type (due to the business logic semantics).
What strategies do you all recommend to do this? I went in this direction because it allowed users to easily layer additional business logic, which would add another layer in the generic type composition.