Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#1253 closed bug (fixed)

Can't use explicit braces/semicolons (i.e. non-layout) at top level with ghci

Reported by: guest Owned by:
Priority: normal Milestone: 6.8.1
Component: Compiler (Parser) Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: read045
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following file is rejected by ghc and ghci, but accepted by hugs.

x =

The work-around is to include 'module Main where' before the opening brace in the first line.

The error reported is:

layoutbug.hs:1:0: parse error on input `{'

I discovered this bug whilst assisting a programmer who uses a screenreader and hence finds layout code quite unhelpful. Blind and partially sighted users in general may well hit this problem!

My reading of the haskell report suggests that the code above is valid haskell98 (looking at the grammar, one alternative for 'module' is 'body', and 'body' can be { topdecls } )

Change History (6)

comment:1 Changed 10 years ago by igloo

Milestone: 6.6.2

The report seems quite clear that we should accept this:

An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be `module Main(main) where'. If the first lexeme in the abbreviated module is not a {, then the layout rule applies for the top level of the module.

but we don't in either 6.6 branch or HEAD.

comment:2 Changed 10 years ago by simonmar


comment:3 Changed 10 years ago by simonmar

Component: CompilerCompiler (Parser)
Resolution: fixed
Status: newclosed
Test Case: read045

Fixed, thanks.

Mon May  7 14:25:14 BST 2007  Simon Marlow <>
  * FIX: #1253 (Can't use non-layout at top level)

comment:4 Changed 9 years ago by igloo

Milestone: 6.8 branch6.8.1

comment:5 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.