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

Achim Schneider barsoap at web.de
Mon Jan 14 12:04:39 EST 2008


Jonathan Cast <jonathanccast at fastmail.fm> wrote:

> 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...
> 
I'm glad you are capable of ever so nobly assigning the purest   
imaginable motives to me. You are a true inspiration.
 
> >> 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.
> 
Yes. I suppose _> is a better idea, or something else beginning with _,
as the rest of the characters could be functions.


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 



More information about the Haskell-Cafe mailing list