
#11276: GHC hangs/takes an exponential amount of time with simple program -------------------------------------+------------------------------------- Reporter: mpickering | Owner: gkaracha Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gkaracha): Ha, finally! It took more than I expected but I found the source: I do not understand why but GHC wraps all patterns in `CoPat`s: {{{#!hs Just (EventBeginDocument |> <Event>_R) Just (EventEndDocument |> <Event>_R) ... }}} Hence, the following match of `translatePat` (in `deSugar/Check.hs`) is triggered: {{{#!hs CoPat wrapper p ty -> do ps <- translatePat p (xp,xe) <- mkPmId2FormsSM ty let g = mkGuard ps (HsWrap wrapper (unLoc xe)) return [xp,g] }}} This means that, e.g. for the first clause, instead of the *expected*: {{{ Just EventBeginDocument }}} The following is generated: {{{ Just (d2JK (EventBeginDocument <- d2JK)) }}} And like this, we end up with a bunch of guards which make the checker explode. The reason I had it translated like this is that `CoPat`s are used for data families, where we have the original and a representation type constructor. Dropping the `wrapper` would give a type error (while it shouldn't) because the two constructors are different so the guaird translation allowed me to match against `d2JK` using the source type (original tyCon) and then match the guard `(EventBeginDocument <- d2JK)` using the internal type (representation tyCon) and avoid the mix-up. It will need some tinkering but I think I can find a workaround. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11276#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler