Language.Haskell.Parser and layout rules

Simon Marlow simonmar at microsoft.com
Thu Feb 17 09:20:38 EST 2005


On 17 February 2005 14:03, Ross Paterson wrote:

> On Thu, Feb 17, 2005 at 01:40:31PM +0100, Mirko Rahn wrote:
>> The function Language.Haskell.Parser.parseModule behaves somehow
>> strange and disagrees with ghc-6.* about the set of accepted inputs.
>> An example: 
>> 
>> -- file T1.hs:
>> main = do args <- getArgs
>>         if null args then return [] else do
>>         ps <- mapM process args
>>         mapM print ps
> 
> The Report (section 9.3, especially notes 1 and 2) says "A nested
> context must be further indented than the enclosing context", so this
> is illegal. GHC and Hugs have innovated here, but only where the
> inner context is 
> a do expression; they don't accept
> 
> f xs = case xs of
>         y:ys -> case ys of
>         z:zs -> zs

GHC also has a bug in this area which we discovered recently, and
affects mixed layout/non-layout code.  This is accepted, and it
shouldn't be:

f x = case x of
         False -> do 
    { return x; }

Cheers,
	Simon


More information about the Libraries mailing list