RE: ghc-6.0 compiler bug

2003-06-06 Thread Simon Peyton-Jones
Yes, this is a known bug, but thank you for reporting it anyway.  I'm
going to fix it as part of my next sweep though.

I enclose a message that gives a workaround.

Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
| Behalf Of Ch. A. Herrmann
| Sent: 05 June 2003 14:28
| To: [EMAIL PROTECTED]
| Subject: ghc-6.0 compiler bug
| 
| Hi,
| 
| playing around with partial evaluation,
| I encountered the following bug:
| 
| 65 ghc --make -fglasgow-exts -package haskell-src Main.hs -o Main
-ddump-splices
| Chasing modules from: Main.hs
| Compiling Power( Power.hs, ./Power.o )
| Compiling Main ( Main.hs, ./Main.o )
| ghc-6.0: panic! (the `impossible' happened, GHC version 6.0):
|   nameModule x {- v a1BE -}
| 
| Please report it as a compiler bug to
[EMAIL PROTECTED],
| or http://sourceforge.net/projects/ghc/.
|

--
| module Power where
| 
|  import Language.Haskell.THSyntax
| 
|  pow :: ExpQ - Int - ExpQ
|  pow x 0   = [| const 1 |]
|  pow x n | n0 = [| $x * $(pow x (n-1)) |]
|

--
| module Main where
| 
|  import Power (pow)
| 
|  main = let x = 2 :: Double
| in putStrLn (show ($(pow [|x|] 5)))
|

--
| Good luck
| --
|  Dr. Christoph Herrmann
|  Teaching and Research Assistant
|  University of Passau, Germany
|  http://www.fmi.uni-passau.de/~herrmann
| ___
| Glasgow-haskell-bugs mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


---BeginMessage---
Thomas

Absolutely right!  There is a total omission in the TH implementation
for the free 'x' in 
\x - $(power 2 [| x |])

You can get round this in a clunky way by wrapping the whole thing in
$[| |], thus

$([| \x - $(power 2 [| x |]) |])

This works, but it's not pretty.  The Right Thing is to fix it, which I
hope to do.

thanks for pointing this out.  TH is pretty subtle

Simon

|  -Original Message-
|  From: Thomas Harke [mailto:[EMAIL PROTECTED]
|  Sent: 10 March 2003 18:15
|  To: [EMAIL PROTECTED]
|  
|  Hi,
|  
|  while experimenting with template haskell I encountered the
following:
|  
|  ] ghc --make Main.hs
|  ] Chasing modules from: Main.hs
|  ] Skipping  Power( Power.hs, ./Power.o )
|  ] Compiling Main ( Main.hs, ./Main.o )
|  ] ghc-5.05: panic! (the `impossible' happened, GHC version 5.05):
|  ] nameModule x {- v a1fV -}
|  ]
|  ] Please report it as a compiler bug to
[EMAIL PROTECTED],
|  ] or http://sourceforge.net/projects/ghc/.
|  ]
|  ]
|  ] make: *** [main] Error 1
|  
|  This was using a version very recently checked out of CVS (Friday, 14
March)
|  
|  The files that caused the problem are attached.
|  
|  --
|  Tom Harke
|  Computer Science and Engineering Department
|  Oregon Graduate Institute
|  
|  Weiler's Law:
|Nothing is impossible for the man who doesn't have to do it himself

___
template-haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/template-haskell

---End Message---


RE: ghc-6.0 compiler bug

2003-06-06 Thread Ch. A. Herrmann
Hi Simon

Simon Yes, this is a known bug,

Sorry that I'm not perfectly aware of everything going
on with Template Haskell.

Simon but thank you for reporting it
Simon anyway.  I'm going to fix it as part of my next sweep though.

Thank you very much. I'm happy to know that it is really possible
to apply the generated code to run-time values; taking the 
idea of the workaround:

 main = $([| do
  s - getLine
  let x = read s :: Double   
  putStrLn (show ($(pow [|x|] 5))) |])
-- 
 Dr. Christoph Herrmann
 Teaching and Research Assistant 
 University of Passau, Germany 
 http://www.fmi.uni-passau.de/~herrmann
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs