
#8761: Make pattern synonyms work with Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: bollmann Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Template Haskell | Version: 8.0.1 Resolution: fixed | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1940 Wiki Page: | -------------------------------------+------------------------------------- Comment (by heisenbug): Replying to [comment:28 goldfire]:
Replying to [comment:27 heisenbug]:
''snip'' No, I don't believe that's possible, because TH doesn't allow "name splices". You'd have to build up the syntax manually, using the `Dec` constructors or the functions from `Language.Haskell.TH.Lib`.
Oh, sure. I'd build as much as possible using a quote and then alter the name by a transformation on the ADT. {{{#!haskell Prelude Language.Haskell.TH> runQ [d| pattern Foo <- 42 where Foo = 43 |] [PatSynD Foo_0 (PrefixPatSyn []) (ExplBidir [Clause [] (NormalB (LitE (IntegerL 43))) []]) (LitP (IntegerL 42))] }}} Swapping out the `Foo_0` looks easy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8761#comment:29 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler