There are two errors here: the syntax of a functional application and the lost versatility.
Function Syntax Syntax
This is the error "function arguments must be separated by spaces or alternating ..."
In the expression sampleTypeToString A(2)you actually have three words, not two:
A (2) . , -, " ". A (2) .
, sampleTypeToString A(2) sampleTypeToString, - A (2). , , , sampleTypeToString , A , .
- , :
sampleTypeToString (A(2))
, , ( ) F # , :
sampleTypeToString (A 2)
:
sampleTypeToString <| A(2)
, , - ( ), A(2) sampleTypeToString.
" obj, int"
. , string sampleTypeToString? , . . , , .
sampleTypeToString sampleType<'a>, , string, 'a. string : , 'a. , , . , 'a, obj.
sampleTypeToString sampleType<obj>, sampleType<'a>, .
? inline. .NET, , ( DEFINE C ++). , 'a , picky string.
let inline sampleTypeToString x =
match x with
| A (value) -> string value
| B (value) -> string value
sampleTypeToString (A 2)
sampleTypeToString (B "abc")
sampleTypeToString (A true)
string, obj:
let sampleTypeToString x =
match x with
| A (value) -> string (box value)
| B (value) -> string (box value)
string, , - . , obj.ToString(). , .
, string .ToString() :
let sampleTypeToString x =
match x with
| A (value) -> value.ToString()
| B (value) -> value.ToString()
, , string.