
On 10/07/2010 22:02, John Meacham wrote:
On Fri, Jul 09, 2010 at 09:33:52AM +0100, Simon Marlow wrote:
On 08/07/2010 09:45, John Meacham wrote:
On Thu, Jul 08, 2010 at 07:09:29AM +0000, Simon Peyton-Jones wrote:
(ie as infix operators) and I have to squizzle around to re-interpret them as prefix operators. Not very cool. Something unified would be a Good Thing.
So, after thinking about it some, I think there may be a somewhat elegant solution.
I like the sound of it. I put the code for the Haskell 2010 fixity resolver together with a little testing framework in the haskell-prime repo:
There is also my one-pass layout algorithm that requires no interaction with the parser that I believe still has promise. It was able to properly layout all the wild code I threw at it (all of nofib). With the addition of that, we may achieve the holy grail of fully independent lexing,layout,parsing,and fixing of haskell code, and a specification that has a direct correspondence to an implementable algorithm!
I actually just noticed that my layout code is now implemented in ghc: http://hackage.haskell.org/trac/haskell-prime/wiki/AlternativeLayoutRule I am curious what the results will be, I know that adding pattern guards to it would be complicated, I will have to check out how my algorithm was modified.
Yes, Ian Lynagh implemented your algorithm in GHC (with several tweaks to implement some of the darker corner cases, I believe). There's also -XAlternativeLayoutRuleTransitional but I'm not sure what that does. There are cases that you can't reasonably handle this way, e.g. g = (let x, y :: Int; (x,y) = (1,2) in x, 3) f xs = [ do x | x <- xs ] My feeling is that if we were to do layout this way it would have to be a simplified version of the current algorithm, so that it is easy to explain both to users and in the report. Perhaps restricting the tokens that can prematurely end a layout context to just the important ones, like ) ] } 'in'. Cheers, Simon