R – Why can’t F# infer the type of this statement

%ffunctional programmingtype-inference

/// I can't do this
let max =  float n |> sqrt |> int64 |> Math.BigInt

/// But this is allowed
let max =  Math.BigInt(float n |> sqrt |> int64)

Best Answer

Class constructors cannot be used without arguments. You can write

let max =  float n |> sqrt |> int64 |> (fun x -> Math.BigInt(x))

if you like. (Offhand I don't know the reason for this restriction, though.)