Questions on the Haskell 2010 report

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I am trying to write a haskell compiler and i have stumbled upon 2 issues that i don't understand in the Haskell report 2010. Btw. these issues are also present in the 98 report. 1) first is this in section 5.1 Module Structure [1]. A module is defined like this. module → module modid [exports] where body | body body → { impdecls ; topdecls } | { impdecls } | { topdecls } You can't see it in this mail because there is no font but the curly braces { } are meant to match the tokens { } and are not meant as repetition. However, as I understand it, the layout parser would modify this code: module Foo where import Bar baz=baz to this code (which doesn't match): module Foo where { import Bar ; baz=baz } and not to this code (which would be required to match): module Foo where { { import Bar } ; { baz=baz } } So as i see the definition should state this instead: module → module modid [exports] where body | body body → { impdecls ; topdecls } | impdecls | topdecls 2) In the same section what is it supposed to mean if "module" consists of only a "body" and not "module modid [exports] where body". 3) In section 10.3 Layout [2] it is written. If a let, where, do, or of keyword is not followed by the lexeme {, the token {n} is inserted after the keyword, where n is the indentation of the next lexeme if there is one, or 0 if the end of file has been reached. Together with this rule L [] (m : ms) = } : L [] ms if m≠0 (Note 6) This results in an error if the program ends in a "where", ... Wouldn't it make more sense to put a {1} in case of EOF or just insert the tokens '{' and '}'. On the other hand if you really won't accept that why not simply say that it is an error. btw. GHC doesn't give an error. [1] http://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1 [2] http://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-1780001... -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJPCdgeAAoJEDLsP+zrbatWIjgP/RLISOIz6xZRDso/mVn+xbwh eMPdeqmzJJYpVm+sDdjmoEIAsrwXtYKc9r8LrlUOugbtXFhYYPcSox7Te4DO+Cm+ X+b8b80UQu1nKNoUofDqAXSQb/n7f5zgmaIoF2uvFieuJTE709oZCmBdTgupVdyJ D16VqmKmqpskNepnQuh9rV7vwSPs4PjnsUQDpxjXDvh0tSdp9byBZPcMwEgQb172 FJAAryCuKFBE8FRG+ANlSw2h8fH7rkMLmkjabje5NKtLa2UMKvBlXYa2p0EZwcd2 /bj/2GTksWdsDmqFp3lQJgPk2uxp5reosTiTk5JQz56GcPOTK3wmL62qDeH3+tdS pX5ZD8HeX8RdkLjuFi0fjiJq3L4HEy+OqHbLWoStPPqfY9clueSUJ0g0Dfc4OukU 0naJlASxKr4ovHBiTinrLI6bTTeeMj9QCDGh5hU0x1hJ5f80iQQaKYpI8cq1DxQv CICBFibFnbJ0Zfzfuk0ZJZ8Db1dJUdEGSYZo/QCtpxXwTyKr4zEU6FYHprScRRX8 H6ZDnVE6ZbzDbaUqeQVBXvUGHF+2vTmDo1EZ80BFhDVHjifvV9eHslbF0XD+NjYY iRPsgDzACYsMxvYaBsRlXWwmwWD+EfNerdHZL6h9dBZICwSr0pu4SCp616BR2BpK IuO4MG/B5vAoCs9cb0lG =O6Wd -----END PGP SIGNATURE-----

On Sun, Jan 8, 2012 at 12:53, Silvio Frischknecht
module → module modid [exports] where body | body body → { impdecls ; topdecls } | { impdecls } | { topdecls }
You can't see it in this mail because there is no font but the curly braces { } are meant to match the tokens { } and are not meant as repetition. However, as I understand it, the layout parser would modify this code:
module Foo where import Bar baz=baz
to this code (which doesn't match):
module Foo where { import Bar ; baz=baz }
and not to this code (which would be required to match):
module Foo where { { import Bar } ; { baz=baz } }
Pardon? As I read the spec you quoted, the former agrees with it and the latter does not. How do you get the (illegal) latter? 2)
In the same section what is it supposed to mean if "module" consists of only a "body" and not "module modid [exports] where body".
If you don't name a module, the module is imputed to be Main and the symbol main is exported from it. See the final paragraph of Section 5.1. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for the response
Pardon? As I read the spec you quoted, the former agrees with it and the latter does not. How do you get the (illegal) latter?
Oh, yes your right. I must have mixed up something.
If you don't name a module, the module is imputed to be Main and the symbol main is exported from it. See the final paragraph of Section 5.1.
Didn't see that I also think I figured out number why there should be an error in number 3. Though I still thinks it's a very roundabout way of saying it Silvio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJPCeimAAoJEDLsP+zrbatWtvQQALa58yEivnJ2BSvwZpAgDGKx SstxyoE2a4dxv+4bVfu2ngJzdtSGjP0Xf0vY7jTL4VO2aDO/uBbHW4wR/tzitEhI vsES1PBrHZHPO+pctVNqaKn9O738tDktF2KU7wu789epTafvkQKeNbmlloZfMrkB W0IlWHsWW3BaqdmBXb8M7nGaBUPyX1iLH3lXU5M5BQnWndv/99A0k+fuoj//TvwI w6N2ct6mI12ohVbBi8xmSANvel5ZePRi4mj3GfnGtFuETRqxqRd/IQNb0VjgTx1k UlpbHA7GDV2OtRavMu0BlfRdYwQJ/eIinFhd3mT1ICZ3mBtbTsZC5JBQi1x4EbFJ /jgFU4DWdskIT3RXjiKXAQxDRRwtvFhqDVA3OxZeKBZAMAVUCvcAGwWpGNMD27/3 OkUptukFkHil6KGUbY3K6IwkGKMK5aBuHOl2ZxCHjZo3rnskfQz8CIk34Dxv/mOG idhZhT/EGv3nkKH0ny1zUEgkFHmkJRS9ytp36ubi1cC4ptTPOkUt6cIeFEhCMmCH bcWIZez1c7xvkTygbQAF6kj8V4vwgxwmYxjga5/kn4toRRmuD6anY/DZd5JJ4/2E RgI24R7hJlBmZLoNpNBOlyhMoDWfE5baECZH2IGiJq+mREskIBVui64LsL5xqJCP gvR1od0nzAkZkHNoowew =Egb5 -----END PGP SIGNATURE-----
participants (2)
-
Brandon Allbery
-
Silvio Frischknecht