[Haskell-cafe] Re: All equations must have the same arity - why?

Jonathan Cast jonathanccast at fastmail.fm
Sun Jan 13 20:57:39 EST 2008


On 13 Jan 2008, at 5:49 PM, Achim Schneider wrote:

> Jonathan Cast <jonathanccast at fastmail.fm> wrote:
>
>> On 13 Jan 2008, at 5:27 PM, Achim Schneider wrote:
>>> Answer #2:
>>>
>>> Because you can't write
>>>
>>> f x = case x of
>>> 	[] -> [1]
>>>         -> sort.nub
>>
>> But why not?
>>
> Because arities aren't lifted to the longest argument list.

I think you lost the point of my question...

>> Treating case as syntax sugar for a higher-order
>> function, so that all binding occurrences of lambdas in the
>> unsugared code are associated with lambdas, is a good thing, and
>> offers a natural way of desugaring the above, one case at a time.
>>
> What about
>
> f x = [1]
> f - = sort.nub
>
> ?
>
> You could also do things like
>
> f - x = (foo x).bar
>
> with it. No more rewriting of pointfree code because of added
> arguments...

So `-' as a pattern means `implicitly apply the RHS to whatever this  
pattern matches'?  I like it.

jcc




More information about the Haskell-Cafe mailing list