[Haskell-cafe] Re: monad subexpressions

Simon Peyton-Jones simonpj at microsoft.com
Fri Aug 3 04:04:36 EDT 2007


See also this thread
http://www.haskell.org/pipermail/haskell-prime/2007-July/002269.html
Magnus made a TH library that does something similar, see
http://www.haskell.org/pipermail/haskell-prime/2007-July/002275.html

Nesting is important. Consider
        do { a <- f x
           ; b <- g a
           ; return (2*b) }

Then you'd like to linearise this to give
        do { return (2 * $(g $(f x))) }

The hardest thing about this project is finding a suitable syntax!  You can't use the same syntax as TH, but it does have a "splice-like" flavour, so something similar would make sense.  $[ thing ] perhaps?  Or %( thing )?  Avoid anything that looks like a TH *quotation* because that suggests the wrong thing.  (| thing |) is bad.

A good plan can be to start a Wiki page that describes the problem, then the proposed extension, gives lots of exmaples, etc.

Simon

| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Chris
| Smith
| Sent: 03 August 2007 04:30
| To: haskell-cafe at haskell.org
| Subject: [Haskell-cafe] Re: monad subexpressions
|
| Neil Mitchell <ndmitchell at gmail.com> wrote:
| > I think this is a fantastic idea, please do so!
| >
|
| Okay, I'll do it then.  If I have a good weekend, perhaps I'll volunteer
| a talk at AngloHaskell after all!  :)
|
| So what about syntax?  I agree with your objections, so we've got
|
| ( <- expr )   -- makes sense, and I think it's unambiguous
| ``expr``      -- back-ticks make sense for UNIX shell scripters
|
| The first is something Simon Peyton-Jones came up with (probably on-the-
| fly) at OSCON, and I rather like it a lot; but I'm concerned about
| ambiguity.  The latter seems sensible as well.  Any other ideas?
|
| --
| Chris Smith


More information about the Haskell-Cafe mailing list