
#15777: Ordering of code in file affects compilation -------------------------------------+------------------------------------- Reporter: chessai | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 8.6.1 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #12088 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): When kind-checking, GHC performs strongly-connected component (SCC) analysis to determine which declarations depend on the presence of other declarations. In your example, the `type Unlifted Stuff = Stuff#` instance declaration depends on the `type instance Rep Stuff = TupleRep '[ 'IntRep, 'IntRep ]` instance declaration in order to kind-check, so a proper SCC analysis should put the former declaration //after// the latter one. Because of #12088, however, this does not happen correctly, and these declarations get processed out of dependency order. The use of a Template Haskell splice (such as `$(pure [])`) is a gruesome hack which forces the declarations following the splice to be processed //after// the declarations preceding the splice. This is often an annoying weakness of Template Haskell, but in this particular case, it happens to work to our advantage :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15777#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler