Language.Haskell.Parser and layout rules
Simon Marlow
simonmar at microsoft.com
Mon Feb 21 05:43:31 EST 2005
On 18 February 2005 16:31, Mirko Rahn wrote:
>> The Report (section 9.3, especially notes 1 and 2) says "A nested
>> context must be further indented than the enclosing context", ...
>
> Okay, I understand, but the behavoir of hugs vs ghc vs
> Language.Haskell.Parser is still strange: The sniplets
>
> ** A:
> g xs = do ys <- workM xs
> if null ys then return [] else do
> zs <- workM ys
> return zs
>
> ** B:
> g xs = do ys <- workM xs
> if null ys then return [] else do
> zs <- workM ys
> return zs
>
> ** C:
> f xs = case xs of
> y:ys -> case ys of
> z:zs -> zs
>
> ** D:
> f x = case x of
> False -> do
> { return x; }
>
> are accepted by
> A B C D
> ghc yes no no yes
> hugs yes no no no
> Language.Haskell.Parser.parseModule no yes yes no
> report no no no no
Hugs is probably the most correct here. A is intentionally parsed by
Hugs and GHC. D is a known bug in GHC.
It looks like Language.Haskell.Parser may have bugs in this area.
Interestingly, Haddock is better than GHC, giving the same results as
Hugs. Haddock's parser is based on Language.Haskell.Parser, so it looks
like a bug has been introduced in Language.Haskell.Parser at some point.
Cheers,
Simon
More information about the Libraries
mailing list