2
我想知道如果一個清單是第二清單的前綴使用下面的代碼:推斷類型是不夠的一般,
prefix :: [a] -> [b] -> Bool
prefix [] _ = True
prefix _ [] = False
prefix (x:xs) (y:ys) = if (x==y) then prefix xs ys else False
但它返回一個錯誤:
Inferred type is not general enough
*** Expression : prefix
*** Expected type : [a] -> [b] -> Bool
*** Inferred type : [a] -> [a] -> Bool
燦有人幫我讓這個工作?