Maybe this topic can be of interest: How to work with type unstable functions? I think it’s rather similar to what you are doing and it has some explanations.
Maybe this topic can be of interest: How to work with type unstable functions? I think it’s rather similar to what you are doing and it has some explanations.