为什么 F# 突然从函数返回值作为 @+行号?

发布于 2024-12-10 14:34:57 字数 415 浏览 0 评论 0原文

我在 F# 中有一些代码工作正常,但现在有任何函数返回与 @ + 行号绑定的 let 名称吗?所以之前当我做这样的事情时:

let sqlData = GetSummary 2011

我会获取数据。现在我得到 sqlData@160 作为返回类型,这会破坏其他需要特定类型的函数。任何关于为什么会突然发生这种情况的帮助将不胜感激。

更新: 所以我将 GetSummary 代码更改为这样,只是为了看看会发生什么:

 let GetSummary fiscalYear =
    let g = 22
    g

没有任何改变。我得到了完全相同的结果,即使我有一个断点,它也不会中断函数。它也不会进入 GetSummary。为什么它会忽略某些功能而不忽略其他功能?

I have some code in F# that was working fine, but now any function returns the name of the let binding with @ + line number? So before when I did something like this:

let sqlData = GetSummary 2011

I would get the data. Now I get sqlData@160 as the return type, which break other functions expecting a specific type. Any help as to why this suddenly started happening would be appreciated.

UPDATE:
So I changed the GetSummary code to this just to see what would happen:

 let GetSummary fiscalYear =
    let g = 22
    g

And nothing changed. I got the exact same results and it would not break in the function even though I have a breakpoint. It also would not step into GetSummary either. Why would it ignore the some functions and not others?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与往事干杯 2024-12-17 14:34:57

我的猜测是您已经更改了 GetSummary 函数中的某些内容,以便它实际上返回一个函数而不是返回数据(当您给它一个参数时)。例如,此代码片段的行为有点相似 - 它返回一些内部内容,并且不进入 bar 函数内部:

> let bar n = printfn "inside bar"; n + 1;;
val bar : int -> int

> let foo n = bar;; // This takes 'n' and returns a function..
val foo : 'a -> (int -> int)

> printfn "%O" (foo 10);; // Here, we call 'foo', but the result is a function!
FSI_0016+it@15-3

My guess is that you've changed something in the GetSummary function, so that it actually returns a function instead of returning the data (when you give it a single argument). For example, this snippet behaves a bit similarly - it returns some internal things and it doesn't step inside the bar function:

> let bar n = printfn "inside bar"; n + 1;;
val bar : int -> int

> let foo n = bar;; // This takes 'n' and returns a function..
val foo : 'a -> (int -> int)

> printfn "%O" (foo 10);; // Here, we call 'foo', but the result is a function!
FSI_0016+it@15-3
夕色琉璃 2024-12-17 14:34:57

好吧,现在我觉得自己真的很蠢。我回去发现我已经将 GetSummary 的定义更改为

GetSummary name fiscalYear

由于我没有传递名称,它认为我正在柯里化该函数,因此出现了奇怪的行为。

感谢您的投入!

Okay, now I feel really stupid. I went back and realized that I had changed the definition of GetSummary to

GetSummary name fiscalYear

Since I was not passing in the name, it thought that I was currying the function, hence the odd behavior.

Thanks for your input!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文