List 为什么Haskell不允许理解中的模式匹配?
我编写了以下(普通)函数:List 为什么Haskell不允许理解中的模式匹配?,list,haskell,scope,list-comprehension,monads,List,Haskell,Scope,List Comprehension,Monads,我编写了以下(普通)函数: h c = [f x | x <- a, f <- b, (a, b) <- c] 但是,GHCi返回错误: <interactive>:24:17: error: Variable not in scope: a :: [a1] <interactive>:20:27: error: Variable not in scope: b :: [t0 -> b1] :24:17:错误:变量不在范围内:a::[a
h c = [f x | x <- a, f <- b, (a, b) <- c]
但是,GHCi返回错误:
<interactive>:24:17: error: Variable not in scope: a :: [a1]
<interactive>:20:27: error:
Variable not in scope: b :: [t0 -> b1]
:24:17:错误:变量不在范围内:a::[a1]
:20:27:错误:
变量不在范围内:b::[t0->b1]
这似乎毫无意义,因为
a
和b
确实在范围内。您的绑定顺序错误
h c = [f x | (a,b) <- c, f <- b, x <- a]
hc=[fx |(a,b)
<interactive>:24:17: error: Variable not in scope: a :: [a1]
<interactive>:20:27: error:
Variable not in scope: b :: [t0 -> b1]
h c = [f x | (a,b) <- c, f <- b, x <- a]