[Template-haskell] two things I wanted from TH today

Simon Peyton-Jones simonpj at microsoft.com
Tue Apr 20 11:49:43 EDT 2004


| > But it doesn't look like Pattern Guards are available in THSyntax
yet.

The question is whether we want THSyntax to absorb all GHC extensions.
I guess the answer does seem to be 'yes, on demand' because the kind of
people who use TH also seem to be the kind of people who use GHC
extensions!


Re Ian's alternatives below, my own preference would be for (1) just
because it's simple and direct.
I think that TH users are savvy enough to absorb THSyntax changes
without much pain, so backward compatibility isn't too big an issue.
Esp since the HEAD contains lots of changes anyway.

Simon


| Hmm, we currently have
| 
| data Body = GuardedB [(Exp,Exp)]
|           | NormalB Exp
| 
| It looks like we would want either
| 
| ----- 1
| data Body = GuardedB [(Guard,Exp)]
|           | NormalB Exp
| 
| data Guard = NormalG Exp
|            | PatG [Stmt]
| -----
| 
| or
| 
| ----- 2
| data Body = GuardedB [(Exp,Exp)]
|           | PatGuardedB [(Guard,Exp)]
|           | NormalB Exp
| 
| data Guard = NormalG Exp
|            | PatG [Stmt]
| -----
| 
| or
| 
| ----- 3
| data Body = GuardedB [(Exp,Exp)]
|           | PatGuardedB [([Stmt],Exp)]
|           | NormalB Exp
| -----
| 
| 1 is the simplest overall, but I think it would set a bad precedent as
| we wouldn't want future extensions to cause TH programs to break.
| 
| 2 and 3 have the advantage that Haskell98+TH users can pretend nothing
| happened. I think I prefer 2 over 3 as it's simpler to see what
happens
| when a GuardedB and PatGuardedB are concatenated.
| 
| So I propose option 2. Does anyone disagree?



More information about the template-haskell mailing list