The following function compiles and works:
shares :: Maybe (Int, L.ByteString) -> Maybe Int
shares a =
case a of
Nothing -> Nothing
Just (x, y) -> Just x
But when rewritten in the following form:
shares :: Maybe (Int, L.ByteString) -> Maybe Int
shares Nothing = Nothing
shares Just (x, y) = Just x
I get errors
Equations for ‘shares’ have different numbers of arguments
I think it's same essentially.
In Haskell, arguments to function are separated by spaces. Therefore, the last equation has two arguments: Just
of type a -> Maybe a
and (x, y)
of type (Int, L.ByteString)
. Since you want one argument, it should instead read:
shares (Just (x, y)) = Just x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With