Explain the ' notation in F#

前端 未结 2 710
[愿得一人]
[愿得一人] 2021-01-17 16:14

I\'m learning F#, when I type any code in Visual Studio and run them on F# Interactive it shows me things like

val foo : x:\'a -> \'a
         


        
2条回答
  •  天涯浪人
    2021-01-17 17:02

    'a represents a type variable, in other words a type that is not determined yet (and doesn't have to be determined yet).

    Note that this is different than a', which is a regular variable whose name is two characters: a and '. Contrary to other languages like C#, the single quote is a permitted character in F# variable names, except as the first character in the name to disambiguate from type variables above.

提交回复
热议问题