[Haskell-cafe] Re: proposal: point free case expressions

Joe Fredette jfredett at gmail.com
Thu Nov 5 14:33:34 EST 2009

Don't these things generally get added as LANGUAGE pragmas though? If  
it's off by default then peoples code should be okay.

Also, I'd prefer something like `cases` as the keyword, rather than  
`case of`, mostly for aesthetics, but also so that, upon visual  
inspection, I wouldn't wonder where the pattern went and potentially  
try to 'fix" the point-free case match.


On Nov 5, 2009, at 1:09 PM, Edward Kmett wrote:

> On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier <monnier at iro.umontreal.ca 
> > wrote:
> > We could really use a case statement in which we skip the  
> scrutinee and make
> > (case of {})' be syntactic sugar for `(\x -> case x of {})'.
> > So we could write:
> >> myFunc = anotherFunc $ case of
> >> Left err -> print err
> >> Right msg -> putStrLn msg
> > A minor syntactical addition, a big win!
> Since this "case" really defines a function, it seems like it would  
> make
> more sense to allow defining anonymous functions by pattern matching.
> I.e. instead of "case of", I think it should use "λ", "\", "fn",  
> or ...
> The problem with all of those options is that they introduce a new  
> keyword into the language and can potentially break existing code.
> Eugene's \{ } avoids that by using a different hole in the grammar,  
> but at the expense of 'un-Haskelly' braces. That and I question how  
> easy it would be to get to parse, because a common idiom seems to be  
> to parse patterns as expressions before converting them to patterns  
> to avoid certain other ambiguities in the grammar, so this requires  
> a { } expression, which may introduce a lot more ambiguity and  
> problems to the grammar than it would seem at first glance.
> -Edward Kmett
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list