尝试通过 foldr 函数实现列表计数
lengthList = foldr (\x s -> s + 1) 0
给出以下错误
* Ambiguous type variable `t0' arising from a use of `foldr'
prevents the constraint `(Foldable t0)' from being solved.
Relevant bindings include
lengthList :: t0 a -> Integer (bound at lenListFoldr.hs:2:1)
Probable fix: use a type annotation to specify what `t0' should be.
These potential instances exist:
instance Foldable (Either a) -- Defined in `Data.Foldable'
instance Foldable Maybe -- Defined in `Data.Foldable'
instance Foldable ((,) a) -- Defined in `Data.Foldable'
...plus one other
...plus 23 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
* In the expression: foldr (\ x s -> s + 1) 0
In an equation for `lengthList':
lengthList = foldr (\ x s -> s + 1) 0
我该如何解决?