Opened 4 years ago

Closed 4 years ago

Last modified 20 months ago

#10855 closed bug (fixed)

GHC rejects code that Haskell 2010 report accepts

Reported by: goldfire Owned by:
Priority: normal Milestone: 7.10.3
Component: Compiler (Parser) Version: 7.10.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Documentation bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


According to The Haskell 2010 Report, the following two modules should compile. But they don't, failing with parse errors:

{-# LANGUAGE Haskell2010 #-}

module Bug where

bool = - case b of False -> 0; True -> (-1)
{-# LANGUAGE Haskell2010 #-}

instance Num (IO a) where
  negate = id

main = - do putStrLn "hi!"

Note the unary - signs.

I'm not sure whether we should complicate the parser to fix these, but we should document the compliance-failure in the manual.

Change History (5)

comment:1 Changed 4 years ago by thomie

Component: CompilerCompiler (Parser)
Type of failure: None/UnknownDocumentation bug

comment:2 Changed 4 years ago by Richard Eisenberg <eir@…>

In 27f9186d/ghc:

Clarify parsing infelicity.

This fixes #10855.

comment:3 Changed 4 years ago by goldfire

Milestone: 7.10.3
Status: newmerge

May as well merge this one.

comment:4 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

comment:5 Changed 20 months ago by Ben Gamari <ben@…>

In be84823/ghc:

Implement BlockArguments (#10843)

This patch implements the BlockArguments extension, as proposed at It also
fixes #10855 as a side-effect.

This patch adds a large number of shift-reduce conflicts to the parser.
All of them concern the ambiguity as to where constructs like `if` and
`let` end. Fortunately they are resolved correctly by preferring shift.

The patch is based on @gibiansky's ArgumentDo implementation (D1219).

Test Plan: ./validate

Reviewers: goldfire, bgamari, alanz, mpickering

Reviewed By: bgamari, mpickering

Subscribers: Wizek, dfeuer, gibiansky, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #10843, #10855

Differential Revision:
Note: See TracTickets for help on using tickets.