ppr of HsDo

Simon Peyton Jones simonpj at microsoft.com
Thu Nov 10 08:24:32 UTC 2016


I think it’s because the  “;” is treated as part of the let not part of the do.  After all, how does the implicit layout of the let know that the let-bindings are finished?

This should work

foo
  = do { let { x = 1 };
         Just 5 }

Now the let bindings are clearly brought to an end.  Or this

foo
  = do { let x = 1
       ; Just 5 }

Now the “’;” is to the left of the x=1 and so brings the let’s implicit layout to an end.

But not this!

foo
  = do { let x = 1; Just 5 }

So it’s a bug in the pretty-printer, not the parser

SImon


From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Alan & Kim Zimmerman
Sent: 10 November 2016 07:01
To: ghc-devs at haskell.org
Subject: ppr of HsDo

The pretty printer turns

foo = do
  let x = 1
  Just 5
into

foo
  = do { let x = 1;
         Just 5 }
which does not parse, complaining about "parse error on input ‘Just’"
Is this a parser error or a ppr problem?  I am keen to fix the ppr to output


foo
  = do let x = 1
       Just 5
but I am not sure if there is a parser bug too.
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20161110/b20070e7/attachment.html>


More information about the ghc-devs mailing list