以下函数编译并运行:
shares :: Maybe (Int, L.ByteString) -> Maybe Int
shares a =
case a of
Nothing -> Nothing
Just (x, y) -> Just x
但是当用以下形式重写时:
shares :: Maybe (Int, L.ByteString) -> Maybe Int
shares Nothing = Nothing
shares Just (x, y) = Just x
我收到错误
Equations for ‘shares’ have different numbers of arguments
我认为它基本相同。
答案 0 :(得分:6)
在Haskell中,函数的参数由空格分隔。因此,最后一个等式有两个参数:类型为.Site.AllPages
的{{1}}和类型为Just
的{{1}}。因为你想要一个参数,所以应该改为:
a -> Maybe a