
#15490: Can Template Haskell and RULES be combined? -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.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 nomeata): Template Haskell is the wrong tool for this, since it deals with Haskell (the surface language), but rules actually apply to Core. But I suppose you can write a GHC plugin that installs a `BuiltInRule` (see https://downloads.haskell.org/~ghc/latest/docs/html/libraries/ghc-8.4.3/Core...) which can have arbitrary functions to decide whether the rule fires, and what to replace it with. Or write a GHC Plugin with a Core2Core pass that simply rewrites the code as desired. In all cases, the plugin will have to be loaded explicitly, i.e. these kind of rules are not exported. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15490#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler