Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 为什么Haskell不允许理解中的模式匹配?_List_Haskell_Scope_List Comprehension_Monads - Fatal编程技术网

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]