[Haskell-cafe] Re: Equations for `foo' have different numbers of
barsoap at web.de
Tue Mar 24 10:58:00 EDT 2009
Manlio Perillo <manlio_perillo at libero.it> wrote:
> There is a limitation, in Haskell, that I'm not sure to understand.
> Here is an example:
> module Main where
> divide :: Float -> Float -> Float
> divide _ 0 = error "division by 0"
> divide = (/)
> main = do
> print $ divide 1.0 0.0
> print $ divide 4.0 2.0
> With GHC I get:
> Equations for `divide' have different numbers of arguments
> With HUGS:
> Equations give different arities for "divide"
> However the two equations really have the same number of arguments.
> What's the problem?
Equations not being what you think they are. They aren't "the symbol
'divide' equals that function" but "lhs of '=', '=', and rhs of '='.
The problem is mostly syntactical, in the sense that most occurrences of
definitions with a different number of arguments are plain typos. The
other might be implementation issues: it makes pattern match rules
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.
More information about the Haskell-Cafe