AlternateLayoutRule
Simon Marlow
marlowsd at gmail.com
Tue May 13 20:32:31 UTC 2014
On 13/05/14 15:04, John Meacham wrote:
> Hi, I noticed that ghc now supports an 'AlternateLayoutRule' but am
> having trouble finding information about it. Is it based on my
> proposal and sample implementation?
> http://www.mail-archive.com/haskell-prime@haskell.org/msg01938.html
Yes it is, but I think we had to flesh it out with a few more cases.
Ian will know more, he implemented it in GHC.
It has never been the default implementation, because it wasn't possible
to cover 100% of the strange ways that code in the wild currently relies
on the parse-error behaviour in the layout rule. You can get it with
-XAlternateLayoutRule though.
I'm not sure what we should do about it. I think Ian's motivation was
to experiment with a view to proposing it as a replacement for the
layout rule in Haskell', but (and this is my opinion) I think it ends up
not being as clean as we might have hoped, and the cases where it
doesn't work in the same way as the old rule aren't easily explainable
to people.
On the other hand, we did find a nice use for it in GHC: the multiline
parser in GHCi can tell whether you've finished typing a complete
expression using the alternate layout rule.
Cheers,
Simon
> https://ghc.haskell.org/trac/haskell-prime/wiki/AlternativeLayoutRule
> implies it has been in use since 6.13. If that is the case, I assume
> it has been found stable?
>
> I ask because I was going to rewrite the jhc lexer and would like to
> use the new mechanism in a way that is compatible with ghc. If it is
> already using my code, so much the better.
More information about the Glasgow-haskell-users
mailing list