在 Haskell 中,如果绑定“隐藏现有绑定”,这意味着什么?

发布于 2024-09-02 09:55:08 字数 439 浏览 1 评论 0原文

当我编译时,我收到来自 GHC 的警告:

警告:“pats”的此绑定隐藏了“match_ignore_ancs”定义中的现有绑定

这是函数:

match_ignore_ancs (TextPat _ c) (Text t) = c t
match_ignore_ancs (TextPat _ _) (Element _ _ _) = False
match_ignore_ancs (ElemPat _ _ _) (Text t) = False
match_ignore_ancs (ElemPat _ c pats) (Element t avs xs) =
   c t avs && match_pats pats xs

知道这意味着什么以及如何修复它吗?

干杯。

I'm getting a warning from GHC when I compile:

Warning: This binding for 'pats' shadows an existing binding in the definition of 'match_ignore_ancs'

Here's the function:

match_ignore_ancs (TextPat _ c) (Text t) = c t
match_ignore_ancs (TextPat _ _) (Element _ _ _) = False
match_ignore_ancs (ElemPat _ _ _) (Text t) = False
match_ignore_ancs (ElemPat _ c pats) (Element t avs xs) =
   c t avs && match_pats pats xs

Any idea what this means and how I can fix it?

Cheers.

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

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

发布评论

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

评论(1

待"谢繁草 2024-09-09 09:55:08

这意味着您在程序中的其他位置定义了一个符号 pats 或从某个库模块导入,并且它在与 match_ignore_ancs 相同的范围内可见,因此当您命名一个参数pats,它隐藏(即“阴影”)现有符号。

只需将 pats 参数重命名为不会发生冲突的名称即可。

It means that you have a symbol pats defined somewhere else in your program or imported from some library module, and it's visible in the same scope as match_ignore_ancs, so when you name a parameter pats, it hides (i.e. "shadows") that existing symbol.

Just rename the pats parameter to something that doesn't have a collision.

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