Equations have different number of arguments [GHC91938]
Haskell functions are defined using equations, with the function name and patterns on the left side of the =
and expressions on the right side. When the function is applied, the patterns in the equations are checked from top to bottom, with the first matching equation being chosen.
Each equation that defines a function must have the same number of patterns to the left of the =
.
Examples
Varying numbers of arguments
In this example, the function f
has type Num a => Maybe a > a > a
. Even though each case of the definition can have this type on its own, one of them has a single argument to the left of the =
and a lambda on the righthand side, and the other has two arguments to the left of the =
. In Haskell, each defining equation must have the same number of arguments prior to the =
.
The program was fixed by moving the lambda’s argument to the left of the =
.
Error Message
Main.hs:1:1: error: [GHC91938]
Equations for ‘f’ have different numbers of arguments
Prog.hs:2:119
Prog.hs:3:120

2  f Nothing = \x > x
 ^^^^^^^^^^^^^^^^^^^...
Main.hs
f Nothing = \x > x
f (Just y) x = y + x
f Nothing x = x
f (Just y) x = y + x