Ad
  • Custom User Avatar

    You probably haven't provided usage of the function. So compiler was confused:

    let sumTwoSmallestNumbers = 
        Seq.sort 
        >> Seq.take 2 
        >> Seq.sum // The type 'System.IComparable' does not support the operator 'get_Zero' 
    

    But if you add something like code below, then type will be inferred as int64.

    sumTwoSmallestNumbers [|5L; 8L; 12L; 19L; 22L|] 
    |> printfn "%A"
    

    Error message gives you a hint though: "Consider adding further type constraints"

  • Custom User Avatar

    A blind guess would be that the error stems from the use of Seq.reduce, which needs to start out with the zero-value of the type at hand. For an integer, that would be 0. However, because of the code before the reduce call, the type might only be known as IComparable, and the zero value cannot be derived from that.
    That's what I think when I see the error message. I only did F# during a holiday a while back, so it's not up front knowledge to me, but I hope this helped in some way.