Template Haskell pattern quotations

Simon Peyton-Jones simonpj at microsoft.com
Thu Feb 4 02:58:06 EST 2010

| My question:  Are Template Haskell pattern quotations (i.e., [p| ...
| |]) not implemented in GHC because they are rather tricky to
| implement, or because there has not been demand for them?

They are tricky!  The trouble is that patterns *bind variables*.  I don't know how to deal cleanly with this. For example
	f $p = ...g...
	g x = ...f...
Are these mutually recursive?  Not if $p expands to something that binds g!  But we need to sort bindings into recursive groups before type checking.  But splices must be typechecked before being run, so TH splices are run by the typechecker.

Unless I have a sudden revelation I don't expect to implement pattern splices anytime soon.  

On the other hand, pattern *quasiquotes* are fine; they are run by the renamer before scope analysis is done.  So you can certainly say
	f [qq| ...blah.. |] = ...g...


More information about the Glasgow-haskell-users mailing list