Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.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 错误:表达式为‘;testListTuple’;有不同数量的论点_Haskell - Fatal编程技术网

Haskell 错误:表达式为‘;testListTuple’;有不同数量的论点

Haskell 错误:表达式为‘;testListTuple’;有不同数量的论点,haskell,Haskell,我正在尝试执行一个函数,根据以下代码获取一个表达式和一个元组列表(一对字符串): module Test where import Data.List type Symbol = String data Expression = Var Symbol -- variable | Lambda Symbol Expression -- abstraction | App Expression Expression -- application deriving

我正在尝试执行一个函数,根据以下代码获取一个
表达式和一个
元组列表(一对字符串)

module Test where

import Data.List

type Symbol = String

data Expression = Var Symbol    -- variable
    | Lambda Symbol Expression  -- abstraction
    | App Expression Expression -- application
    deriving (Eq, Read)

expTest = Lambda "x" $ Lambda "y" $ (Var "x" `App` Var "y")

testListTuple :: Expression -> [(Symbol,Symbol)] -> [Symbol]
testListTuple (exp) ((a,b):xs) = functionTest (exp) (a) (b) : testListTuple (exp) (xs)
testListTuple _          = []


functionTest :: Expression -> Symbol -> Symbol -> Symbol
functionTest _ a b = a ++ b

runTest = testListTuple expTest [("a", "b"), ("c", "d")]
但是,将显示以下错误:


解决此错误后,我仍将完成
函数测试的实现

问题完全在于编译器所说的内容。
testListTuple
的方程具有不同数量的参数

第一个等式有两个:
testlistuple(exp)((a,b):xs)=……

第二个有一个:
testlistuple\u=[]

正确的定义是:

testListTuple :: Expression -> [(Symbol,Symbol)] -> [Symbol]
testListTuple exp ((a,b):xs) = functionTest exp a b : testListTuple exp xs
testListTuple _ _ = []

UH给他们同样数量的争论?我很惊讶我竟然忘记了那个小细节。一个非常愚蠢的错误。打扰一下