在Haskell中,如果绑定“阴影现有绑定”,那么这意味着什么? [英] In Haskell, what does it mean if a binding "shadows an existing binding"?
问题描述
警告:'pats'的绑定会影响现有的绑定'match_ignore_ancs'的定义
以下是函数:
match_ignore_ancs(TextPat _ c)(Text t)= ct
match_ignore_ancs(TextPat _ _)(Element _ _ _)= False
match_ignore_ancs(ElemPat _ _ _)(Text t)= False
match_ignore_ancs(ElemPat _ c pats)(Element t avs xs)=
ct avs&& match_pats pats xs
任何想法意味着什么以及我如何解决它?
干杯。
这意味着你有一个符号 pats
定义在程序的其他位置或从某个库模块导入,并且它在与 match_ignore_ancs
相同的作用域中可见,所以当您命名参数 pats
,它会隐藏(即阴影)现有符号。
只需重命名轻拍
参数到没有碰撞的东西。
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.
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.
这篇关于在Haskell中,如果绑定“阴影现有绑定”,那么这意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!