Home > front end >  how to add annotation to the type of the argument?
how to add annotation to the type of the argument?

Time:07-17

A unique overload for method 'GetBytes' could not be determined based on type information prior to this program point. A type annotation may be needed.

enter image description here

CodePudding user response:

if you dispense with the function composition the issue goes away

let terminalStringWidth (s: string) = 
    System.Text.Encoding.Unicode.GetBytes s
    |> Seq.filter (fun x -> int x <> 0b0) 
    |> Seq.length

or explicitly tell the compiler the type you want to select

let terminalStringWidth s = 
    (System.Text.Encoding.Unicode.GetBytes : string -> _)
    >> Seq.filter (fun x -> int x <> 0b0) 
    >> Seq.length

personally I wouldnt write this point free, I used to always try to, but actually for me, it got in the way.

  • Related