| First, I noticed that if I put a function using TH, and that function
is
| called by main, and both are in the same file, I get errors about
using
| something during stage 0 that isn't available until stage 1.  From
this
| I assumed that the TH function and main have to be in separate
| compilation units.  Is this correct?

Yes it is, and for good reason.  Did you read the documentation?  It's
in ghc/docs/using/glasgow_exts.sgml,
or you can typeset it into html by changing into ghc/docs and saying
'make html'.

| I changed the code to do this (make two files), and the code now loads
| under ghci and compiles and links under ghc, but does not do what I
| expected.

Well, you definitely need a top level splice, thus

        main = $(thTestMethod "foo") "baz"

The "foo" is ignored (note that arg x is ignored in your defn of
thTestMethod), and the returned function needs an argument.

Anyway, it should fail the type checker as you have it.  I'll
investigate.

Simon


| 
| Here is what I did:
| 
| First file:
| module Test1 where
| import IO
| import System
| import Language.Haskell.THSyntax
| 
| thTestMethod x = [|\x -> putStrLn x|]
| 
| 
| 
| Second file:
| 
| import Test1
| 
| main =
|       thTestMethod "hello, there"
| 
| 
| When I execute main (in ghci), I get the following two lines:
| 
| Loading package haskell98 ... linking ... done.
| Loading package haskell-src ... linking ... done.
| 
| and then nothing.
| 
| I'm expecting to see a string printed.  What am I doing wrong here?
| 
| TIA,
| 
| 
| 
| --
| Seth Kurtzberg
| M. I. S. Corp
| 480-661-1849
| Pager 888-605-9296, or [EMAIL PROTECTED]
| 

_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to