I have many different types that have a common goal, but little in common. For explanation, they may also be as follows:
type blah<'a> = Blah of 'a type huha<'a> = Huha of 'a
I often need to repeat a large piece of a template that can enter a function line by line:
let f (x:something<int>) (g:something<char> -> float) : float =
But this will require somehow the forced execution of two topics in the same type. In other words, I would like to be able to call the function f like:
f (Blah 1) (fun (b:blah<float>) -> .... ) f (Huha 1) (fun (b:huha<float>) -> .... )
Obviously, the trivial solution is to create a discriminated union of all types that the function f could fulfill, and make each g (i.e. f the second argument) to check if it received the type that it was expecting. But this means that the massive type, which forces the universe to recompile every time something changes, and this doesn't look like type checking at runtime, also helps a lot.
So, can anyone see a way to do what I want in the form? Thank you very much.
source share