If you want to use a match, the inline keyword is not required, but if you want to use the built-in function and "hat types", use overloading instead of matching:
type Sqrt = Sqrt with // Dummy overload in order to get the right types inferred (will never reach here) static member inline ($) (Sqrt, _:^t when ^t:null and ^t: struct) = id // Existing sqrt static member inline ($) (Sqrt, x:'a) :'a = sqrt x // Your Newton-Raphson based sqrt's static member ($) (Sqrt, x:int ) = sqrtForInt x static member ($) (Sqrt, x:bigint) = sqrtForBigInt x let inline sqrt (x:'t) :'t = Sqrt $ x
The return type will always be the same as the input type, and the implementation of the selected sqrt will depend on that type. This selection will be performed at compile time, which is the main difference between the matching method, which is allowed at run time.
If I endure a dummy overload, it will have the same problem as your code: this will require an sqrt constraint.
source share