haskell - Why am I getting the "Equations for ... have different numbers of arguments" message? -


the following function compiles , works:

shares :: maybe (int, l.bytestring) -> maybe int                                                                                                                                                             shares =                                                                                                                                                                                                       case of                                                                                                                                                                                                        nothing        -> nothing                                                                                                                                                                                    (x, y)    -> x 

but when rewritten in following form:

shares :: maybe (int, l.bytestring) -> maybe int                                                                                                                                                             shares nothing = nothing                                                                                                                                                                                     shares (x, y) = x 

i errors

equations ‘shares’ have different numbers of arguments 

i think it's same essentially.

in haskell, arguments function separated spaces. therefore, last equation has 2 arguments: just of type a -> maybe a , (x, y) of type (int, l.bytestring). since want 1 argument, should instead read:

shares (just (x, y)) = x 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -