[Haskell-cafe] All equations must have the same arity - why?
Roman Leshchinskiy
rl at cse.unsw.edu.au
Sun Jan 13 22:20:05 EST 2008
Neil Mitchell wrote:
> Hi,
>
> It's nice to write functions in point free style:
>
> f = sort . nub
>
> But sometimes I have to add an extra case, on a certain value:
>
> f [] = [1]
> f = sort . nub
>
> But now these equations have different arities, and its rejected by
> Haskell. Why does this not simply desugar to:
>
> f [] = [1]
> f x = (sort . nub) x
>
> i.e. lift the arities to the longest argument list.
>
> Is there a reason this isn't done?
In addition to the sharing problem, consider
f True x = x
f False = undefined
Because of seq, the second equation is not equivalent to the eta-expanded
f False x = undefined x
Roman
More information about the Haskell-Cafe
mailing list