Use inline :
let inline sum a b = a + b
UPDATE:
If you are interested in writing your own polymorphic number functions, you should use inline and LanguagePrimitives .
Here is a polymorphic cosine function from a stream Converting a Haskell polymorphic cosine function to F # :
let inline cosine n (x: ^a) =
let one: ^a = LanguagePrimitives.GenericOne
Seq.initInfinite(fun i -> LanguagePrimitives.DivideByInt (- x*x) ((2*i+1)*(2*i+2)))
|> Seq.scan (*) one
|> Seq.take n
|> Seq.sum
source
share