我正在尝试将一个有区别的联合转换为字符串,但我不明白为什么这个代码不起作用.
type 'a sampleType =
| A of 'a
| B of 'a
let sampleTypeToString x =
match x with
| A (value) -> string value
| B (value) -> string value
Run Code Online (Sandbox Code Playgroud)
这是fsharp交互输出
sampleTypeToString A(2);;
Stopped due to error
System.Exception: Operation could not be completed due to earlier error
Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized at 3,19
This expression was expected to have type
'obj'
but here …Run Code Online (Sandbox Code Playgroud)