
This all sounds great except for one thing. Do we have a plan for actually loosening the stage restriction? The stage restriction exists for technical reasons, not conceptual reasons.
The stage restriction currently applies to the module as a whole. It says you cannot use an identifier that was defined in a module within a splice in the same module. Clearly if the use is in a later declaration group than the definition, there is no problem in principle with lifting
#9813: Error when reifying type constructor -------------------------------------+------------------------------------- Reporter: owst | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.8.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): Phab:D1899 Wiki Page: | -------------------------------------+------------------------------------- Comment (by owst): Replying to [comment:27 rwbarton]: the restriction. But in order to do so, we would have to run the declaration group containing the definition through the entire compiler pipeline, right up to linking, so that we can load it to run the splice in the latter declaration group to begin type checking it. GHC just isn't organized to work that way currently. An incredibly good point. To answer the first question simply: I don't, no. I haven't hacked on GHC before, so was attempting to flesh out my original bug report to find a change that I might get my teeth into. I have to admit I hadn't thought about the technical barriers and thus rather haphazardly threw about the "let's loosen the stage restriction" part!
The user's guide has this to say on the subject: ...
Indeed - I pasted that very snippet in comment:14, but I hadn't appreciated what the technical barriers were. What do you think is a sensible step forward? Change 2.b. in my previous comment to "Process NS first, then S. Splices within S can refer (via reify but ''not'' evaluation) to all names declared in NS or previous DGs), but no names within S"? That way, my original program in this ticket would work, but I wouldn't need any of the complexity of changing the stage restriction too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9813#comment:28 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler