[GHC] #1476: Template Haskell: splicing types and patterns

GHC trac at galois.com
Tue Feb 5 12:54:58 EST 2008


#1476: Template Haskell: splicing types and patterns
------------------------------+---------------------------------------------
 Reporter:  igloo             |          Owner:             
     Type:  bug               |         Status:  new        
 Priority:  normal            |      Milestone:  6.10 branch
Component:  Template Haskell  |        Version:  6.6.1      
 Severity:  normal            |     Resolution:             
 Keywords:                    |     Difficulty:  Unknown    
 Testcase:                    |   Architecture:  Unknown    
       Os:  Unknown           |  
------------------------------+---------------------------------------------
Comment (by fons):

 Replying to [comment:2 simonpj]:
 > GHC HEAD now has Geoff Mainland's quasi-quoting patch, which does allow
 splicing into patterns.  (But not types.)

 Cool! I have just read the paper and seems to add a lot of possibilities
 for embedding DSLs in Haskell.


 > I wonder if that helps?

 Yes, it would certainly help (assuming there is a Haskell quasiquote
 parser available).

 The fact that custom quasiquotes (I don't know if it's an appropiate term
 to call Mainland's work) are already working with GHC 6.9, makes me think
 that implementing TH pattern quasiquoting/splicing should be indeed very
 similar.


 In fact, Mainland's quasiquotes could be viewed as syntactic sugar for TH
 quasiquotes

 Using the new quasiquotes one can do something like

 {{{

 expParser :: String -> Q Exp
 patParser :: String -> Q Pat


 expr = QuasiQuoter expParser patParser


 [$exp|randomstring|]

 }}}

 Which would be equivalent to (quasiquoting/splicing was working for
 patterns for TH).

 {{{

 expParser :: String -> Q Exp
 patParser :: String -> Q Pat

 $(expParser "randomstring")
 $(patParser "randomstring")

 }}}

 The only major difference I see is that with Mainland's implementation the
 pattern or expression parser is dynamically chosen depending on its
 context.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1476#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list