Why can't F # infer the type of this statement?

/// 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) 
+4
source share
2 answers

Class constructors cannot be used without arguments. You can write

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

if you want to. (However, I do not know the reasons for this restriction.)

+3
source

In my version of F # (1.9.4.19 on Mono), both versions fail:

The member or object constructor 'BigInt' takes 0 argument(s) but is here given 1. The required signature is 'Math.BigInt()'.

I can use

 let max = float n |> sqrt |> int64 |> Math.BigInt.of_int64 

to get bigint or

 let max = float n |> sqrt |> int64 |> Math.BigInt.FromInt64 

to get Math.BigInt .

0
source

All Articles