2

What is that "arg00" in the type of Fsharp.Text.Lexing's LexBuffer<char>.LexemeString?

> LexBuffer<char>.LexemeString;;
val it : arg00:LexBuffer<char> -> string
zell
  • 9,830
  • 10
  • 62
  • 115

1 Answers1

2

The short answer is that F# can sometimes keep track of argument names when printing the type of a function. In this case, arg00 is an implicit name generated by the compiler for the first argument of the LexemeString operation.

The longer answer is that F# is a bit inconsistent when dealing with function arguments. If you define a function using let, the output will include arguments:

> let foo a b = a + b;;
val foo : a:int -> b:int -> int

If you just a function as a value through its name, the result is treated as a function value (with parentheses around it) and the argument names are omitted:

> foo;;
val it : (int -> int -> int) = <fun:it@4-2>

However, if you define a static member and access it, then the compiler still attempts to print the argument names, but cannot access them (because the member has now been turned into a value) and so it prints implicitly generated names like arg00:

> type A = 
    static member Foo a b = a + b;;
type A = (...)

> A.Foo;;
val it : arg00:int -> arg10:int -> int
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553