Skip to main content
Reword for conciseness
Source Link
Jwosty
  • 3.6k
  • 2
  • 23
  • 36

Need to useprovide a method on variabletype annotation for whicha variable so that you haven't yet constrained the typecan call a method on it? Just compare it against a literal of the type you want it to be then throw away the result to annotate that variable's type:

let f (x:string)=x.Length let f x=x="";x.Length 

Need to use a method on variable for which you haven't yet constrained the type? Just compare it against a literal of the type you want it to be then throw away the result to annotate that variable's type:

let f (x:string)=x.Length let f x=x="";x.Length 

Need to provide a type annotation for a variable so that you can call a method on it? Just compare it against a literal of the type you want it to be then throw away the result:

let f (x:string)=x.Length let f x=x="";x.Length 
Source Link
Jwosty
  • 3.6k
  • 2
  • 23
  • 36

Need to use a method on variable for which you haven't yet constrained the type? Just compare it against a literal of the type you want it to be then throw away the result to annotate that variable's type:

let f (x:string)=x.Length let f x=x="";x.Length