[Haskell-cafe] Re: Lambda-case / lambda-if
nicolas.pouillard at gmail.com
Fri Oct 8 08:41:25 EDT 2010
On Fri, 8 Oct 2010 01:13:20 +0300, Lauri Alanko <la at iki.fi> wrote:
> On Thu, Oct 07, 2010 at 02:45:58PM -0700, Nicolas Pouillard wrote:
> > On Thu, 07 Oct 2010 18:03:48 +0100, Peter Wortmann <scpmw at leeds.ac.uk> wrote:
> > > Might be off-topic here, but I have wondered for a while why Haskell
> > > doesn't support something like follows:
> > >
> > > do case (<- m) of ...
> > >
> > > With the more general rule being:
> > >
> > > do ... e (<- m) g
> > > =>
> > > ... m >>= \tmp -> e tmp g
> Your "general" rule doesn't subsume your case example, since a case
> expression is not an application. I think you mean something like
> do C[(<- m)]
> m >>= \tmp -> C[tmp]
> where C is an arbitrary expression context. It could further be
> generalized to allow several (<- ...) subterms in an expression, with
> implied left-to right sequencing. Frankly, that seems like a very
> attractive way to make the do-notation into a more practical
> imperative sub-language.
This is clearer. However this does not seems very robust against manual
refactoring of the "do" notation.
Imagine find this code:
And I don't see the (<- s2) in C, and so I refactor it as:
s1 >> C[(<- s2)]
And so the s2 get affected somewhere else.
More information about the Haskell-Cafe