
#10823: Expose keepAlive to Template Haskell -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): It's a bit of a hack, but there's a workaround here. Define this in some available module: {{{ data Anything = forall a. Mk a class KeepAlive (what :: Symbol) where whatToKeep :: proxy what -> Anything }}} And then generate this using existing TH: {{{ instance KeepAlive "gt" where whatToKeep _ = Mk gt }}} Then GHC will mark `gt` as used. This is ugly, but it should work well in practice. In the effort to keep TH from bloating too much, I would lean against adding new features to support operations that can be simulated well today. Feel free to try to convince me otherwise -- I'm not dead set in this position. But I'm worried about feature creep here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10823#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler