Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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
Haskell 在何处分析错误_Haskell - Fatal编程技术网

Haskell 在何处分析错误

Haskell 在何处分析错误,haskell,Haskell,在此代码中 neighbours :: CityMap -> District -> [District] neighbours (CM (_,rs)) b = mapMaybe neighbour rs where neighbour (p,q) | b == p = Just q --parse error (possibly incorrect indentation or mismatched brackets) | b == q

在此代码中

neighbours :: CityMap -> District -> [District]
neighbours (CM (_,rs)) b = mapMaybe neighbour rs
    where neighbour (p,q)
        | b == p    = Just q --parse error (possibly incorrect indentation or mismatched brackets)
        | b == q    = Just p
        | otherwise = Nothing

我必须首先解析«|»

防护装置的缩进必须比它们所属函数的名称更深,例如:

neighbours :: CityMap -> District -> [District]
neighbours (CM (_,rs)) b = mapMaybe neighbour rs
    where neighbour (p,q)
           | b == p    = Just q 
           | b == q    = Just p
           | otherwise = Nothing
这是因为在where之后,您定义了一个(本地)函数
neighbor
,它也必须遵循布局规则;如果防护装置更靠左,则它不是
邻居定义的延续。您会在一个类似以下内容的文件中遇到相同的错误:

  neighbour (p,q)
| b == p   = Just q

防护装置的缩进深度必须超过其所属功能的名称,例如:

neighbours :: CityMap -> District -> [District]
neighbours (CM (_,rs)) b = mapMaybe neighbour rs
    where neighbour (p,q)
           | b == p    = Just q 
           | b == q    = Just p
           | otherwise = Nothing
这是因为在where之后,您定义了一个(本地)函数
neighbor
,它也必须遵循布局规则;如果防护装置更靠左,则它不是
邻居定义的延续。您会在一个类似以下内容的文件中遇到相同的错误:

  neighbour (p,q)
| b == p   = Just q

检查缩进。制表符是8个空格。@chirlu,我用了4个空格。我想你的守卫需要超过缩进的开头。制表符是8个空格。@chirlu,我用4个空格。我想你的卫兵需要超过邻居的开头