[Template-haskell] TH problem

Simon Peyton-Jones simonpj at microsoft.com
Wed Nov 30 08:49:13 EST 2005


There is a bug in GHC: mkName ":" doesn't work right.

     let pcons x xs = return $ InfixP x (mkName ":") xs

The reason is that ":" is built-in syntax, and I wasn't handing that
right.

You can get around it by replacing the call to mkName by a quoted name,
thus:

     let pcons x xs = return $ InfixP x '(:) xs

but I will fix the bug.

Simon


| -----Original Message-----
| From: template-haskell-bounces at haskell.org
[mailto:template-haskell-bounces at haskell.org] On
| Behalf Of Ch. A. Herrmann
| Sent: 29 November 2005 16:55
| To: template-haskell at haskell.org
| Subject: [Template-haskell] TH problem
| 
| Dear TH gurus,
| 
| I'm desperately trying to convert the old TH examples to work with
ghc-6.4.1
| and got stuck with a problem I cannot explain. Although the splice
seems
| to be correct, the compiler complains about the (:) in the gerated
| pattern match.
| I appended the source files. They are not very nice right now, because
all
| guidance I have are the types generated by haddock and all effort I
spent
| was to make them fit somehow.
| Please tell me where the error is and how to proceed or, even
| better, please send me the corrected source files back.
| 
| Many thanks in advance.
| 
| Christoph
|
------------------------------------------------------------------------
----------------
| Loading package base-1.0 ... linking ... done.
| Compiling Zip              ( ./Zip.hs, interpreted )
| Compiling Sel              ( ./Sel.hs, interpreted )
| Compiling Main             ( Main.hs, interpreted )
| Loading package haskell98-1.0 ... linking ... done.
| Loading package haskell-src-1.0 ... linking ... done.
| Loading package template-haskell-1.0 ... linking ... done.
| Main.hs:16:18:
|      Main.hs:16:18-23: Splicing expression
|          zipN 3
|        ======>
|          let
|            zp[a4fV] = \ y1 y2 y3
|                           -> case (y1, y2, y3) of
|                                (x1 : xs1, x2 : xs2, x3 : xs3)
|                                  -> ((x1, x2, x3) `GHC.Base.:`
(zp[a4fV]
| xs1 xs2 xs3))
|                                (_, _, _) -> GHC.Base.[]
|          in zp[a4fV]
|      In the second argument of `($)', namely `$[splice](zipN 3) as bs
cs'
|      In a 'do' expression: print $ ($[splice](zipN 3) as bs cs)
|      In the definition of `main':
|          main = do
|                   let as = ['a' .. 'e']
|                       bs = map toUpper as
|                       cs = map ord as
|                   print $ ($[splice](zipN 3) as bs cs)
|                   let ds = [1 .. ]
|                   print $ ($[splice](zipN 4) ds as bs cs)
|                   print $ ($[splice](sel 1 3) (2, 'a', 6))
| 
| Main.hs:16:18: Not in scope: data constructor `:'
| 
| Main.hs:16:18: Not in scope: data constructor `:'
| 
| Main.hs:16:18: Not in scope: data constructor `:'
| Failed, modules loaded: Sel, Zip.
| --
|   Christoph
| 
| 
| 
| 



More information about the template-haskell mailing list