"字符串*字符串"在F#中的含义是什么?

Fen*_*Liu 0 f#

到处搜寻.使用参数查看https://github.com/fsharp/FAKE/blob/master/src/app/Fake.IIS/IISHelper.fs#L64string * string.试图在F#代码中实例化并收到错误FS0010:在表达式中此点或之前包含结构化构造.

这个世界是什么以及如何实例化这个?

Jus*_*mer 6

string*string是一对两个字符串,大致相等Tuple<string, string>.string*int*decimal然后大致等于Tuple<string, int, decimal>.

您创建string*string使用以下表达式的实例"first", "second".string*int*decimal像这样创建一个实例"1", 2, 3.0M.

有关元组的更多信息,请参阅:https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/tuples

如果您认为F#具有用于创建类型的代数,则更容易看到此表示法的基本原理; *创建元组并|创建联合.

// Tree is roughly equal to having an interface Tree 
//  with three implementations Empty, Leaf and Fork
type Tree<'T> =
  | Empty
  | Leaf  of 'T
  | Fork  of Tree<'T>*Tree<'T>
Run Code Online (Sandbox Code Playgroud)

正如Scott Wlaschin演示的那样,拥有用于创建类型的代数是非常强大的:https://fsharpforfunandprofit.com/ddd/