0

爲什麼在此代碼中出現分析錯誤?模式Haskell中的解析錯誤

data One = H| I deriving (Read,Show,Eq) 
data E = A | B deriving (Read,Show,Eq) 
type L = [E] 

fun1 :: One -> E -> One 
-- function for fun1 is here 

fun2 :: One -> L -> One 
fun2 a [] = a 
fun2 a x:xs = fun2 (fun1 a x) xs --<<< I am getting error here 
+0

的可能的複製[Haskell中:解析在圖案錯誤](https://stackoverflow.com/questions/8561762/haskell-parse-error-in-pattern) – 2017-09-06 07:38:39

回答

3

嘗試:

fun2 a (x:xs) = fun2 (fun1 a x) xs