简体   繁体   English

f#表达式的类型

[英]Type of an f# expression

I'm looking for a way to find out the type of an f# expression. 我正在寻找一种找出f#表达式类型的方法。 Something similar to Haskell's type function. Haskell's type函数类似。

IDE:s like VS & VS Code (+ Ionide) can help you with this. VS和VS Code(+ Ionide)之类的IDE:可以帮助您。 Otherwise what I do is that I assign the expression to an obviously invalid binding like: 否则,我要做的就是将表达式分配给显然无效的绑定,例如:

let x : unit = <the_expression>

The compiler will fail and tell you what it found that didn't match unit. 编译器将失败,并告诉您所发现的与单元不匹配的内容。 If the compiler doesn't fail the _ expression is unit. 如果编译器没有失败,则_表达式为unit。 I don't think there's some like _ in haskell to ask the compiler "What do you expect here?". 我认为在haskell中不会出现类似_问题来询问编译器“您在这里期望什么?”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM