我想知道一个列表是否是第二个列表的前缀,使用以下代码:
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
有人可以帮我解决这个问题吗?