Language.Haskell.Parser and layout rules

Ross Paterson ross at
Thu Feb 17 09:03:25 EST 2005

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

More information about the Libraries mailing list