
I was reading the good old template haskell paper by Sheard and Peyton Jones [1]. It looks like some API have changed, but things seems to be more or less the same. I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a dynamic generated string for the format, but that's not a practical drawback (I can't think of a practical reason for using anything other than a string literal for format anyway). Anyhow, what is gained by the template programming in that case is really the flexibility in the type system. You can generate the function with the correct type on the fly, during compiling. That's nice enough, but the article keeps saying that templates are nice for implementing your own custom compiler optimizations. I can see that you really can do so, but I fail to think of a good practical example where templates would be hands down the best approach. Perhaps haskellers with more experience have real life examples they've bumped into. So, please, share your experience with us. [1] http://research.microsoft.com/en-us/um/people/simonpj/papers/meta-haskell/me...

On Mar 19, 2010, at 12:01 , Rafael Almeida wrote:
I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a dynamic generated string for the format, but that's not a practical drawback (I can't think of a practical reason for using anything other than a string literal for format anyway).
Localization via message files. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Hi Rafael There is a paper describing a variant of Conal Elliott's Pan implemented with Template Haskell - PanTH - which you might find interesting: Optimising Embedded DSLs using Template Haskell Sean Seefried, Manuel Chakravarty, and Gabriele Keller http://www.haskell.org/th/papers/th-pan.ps Best wishes Stephen
participants (3)
-
Brandon S. Allbery KF8NH
-
Rafael Almeida
-
Stephen Tetley