Permalink
Browse files

Merge pull request #3 from limdauto/master

Deprecate global in favor of varE.
  • Loading branch information...
2 parents 6b40dd9 + 4d23fbf commit b99a0d2426116374d597e3a9535af28702e42e31 @leonidas-ci leonidas-ci committed Jan 10, 2016
Showing with 3 additions and 3 deletions.
  1. +3 −3 2011/2011-12-27-template-haskell.md
@@ -2,7 +2,7 @@
I've been trying to learn [Template Haskell](http://www.haskell.org/haskellwiki/Template_Haskell) lately, but finding easy to understand, up-to-date tutorial material seems to be somewhat of a challenge, so I decided to write down my experiences while trying to decipher the basics of Haskell meta-programming.
-The code in this post has been tested with GHC 7.0.3 and template-haskell 2.5.0.0.
+The code in this post has been tested with GHC 7.10.3 and template-haskell 2.10.0.0.
## Quotations
@@ -89,11 +89,11 @@ Next, we are going to build a quotation for a function that takes a record and s
```haskell
let showField :: Name -> Q Exp
- showField name = [|\x -> s ++ " = " ++ show ($(global name) x)|] where
+ showField name = [|\x -> s ++ " = " ++ show ($(varE name) x)|] where
s = nameBase name
```
-We use the expression quotation to generate a lambda function that returns the string "*name* = *value*". The content of the quotation is just regular Haskell code, except for the splice `$(global name)`, which is used to access the getter function for the specific named field. It is also noteworthy that we are able use the local variable `s` inside the quotation as is. In the generated AST, it will come out as a plain string literal.
+We use the expression quotation to generate a lambda function that returns the string "*name* = *value*". The content of the quotation is just regular Haskell code, except for the splice `$(varE name)`, which is used to access the getter function for the specific named field. It is also noteworthy that we are able use the local variable `s` inside the quotation as is. In the generated AST, it will come out as a plain string literal.
Now that we can generate code for showing a single field, we simply need to iterate all the different field names.

0 comments on commit b99a0d2

Please sign in to comment.