[Haskell-cafe] Questions on the Haskell 2010 report
Silvio Frischknecht
silvio.frischi at gmail.com
Sun Jan 8 18:53:41 CET 2012
-----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-17800010.3
-----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-----
More information about the Haskell-Cafe
mailing list