Call to arms: lambda-case is stuck and needs your help

Edward Kmett ekmett at gmail.com
Thu Jul 5 23:04:43 CEST 2012


I really like the \of proposal!

It is a clean elision with \x -> case x of becoming \of

I still don't like it directly for multiple arguments.

One possible approach to multiple arguments is what we use for multi-argument case/alt here in our little haskell-like language, Ermine, here at S&P CapitalIQ, we allow for ',' separated patterns, but without surrounding parens to be treated as a multi argument case and alt pair. Internally we desugar our usual top level bindings directly to this representation. When mixed with the \of extension, this would give you:

foo :: Num a => Maybe a -> Maybe a -> Maybe a
foo = \of
  Just x, Just y -> Just (x*y)
  _, _ -> Nothing

but it wouldn't incur parens for the usual constructor pattern matches and it sits cleanly in another syntactic hole.

A similar generalization can be applied to the expression between case and of to permit a , separated list of expressions so this becomes applicable to the usual case construct. A naked unparenthesized , is illegal there currently as well. That would effectively be constructing then matching on an unboxed tuple without the (#, #) noise, but that can be viewed as a separate proposal' then the above is just the elision of the case component of:

foo mx my = case mx, my of
  Just x, Just y -> Just (x*y)
  _, _ -> Nothing

On Jul 5, 2012, at 2:49 PM, wagnerdm at seas.upenn.edu wrote:

> Quoting wagnerdm at seas.upenn.edu:
> 
>> Well, for what it's worth, my vote goes for a multi-argument \case. I
> 
> Just saw a proposal for \of on the reddit post about this. That's even better, since:
> 
> 1. it doesn't change the list of block heralds
> 2. it doesn't mention case, and therefore multi-arg \of is perhaps a bit less objectionable to those who expect "case" to be single-argument
> 3. 40% less typing!
> 
> Can I change my vote? =)
> ~d
> 
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



More information about the Glasgow-haskell-users mailing list