GHC doesn't compile Happy example
Mon, 1 Oct 2001 17:06:20 -0300

Hello all.

	I'm trying to use GHC to compile the example parser in Happy, 
but with no success. I'm using GHC 5.02 for W2K, and I'm not 
quite sure what to do to make it work. I successfully compiled 
some small test cases, to see if I had installation problems, and 
they compiled just fine.

	First, the Happy example uses some functions that exist in 
Hugs but not in GHC, like isAlpha, isDigit and isSpace (I think so, 
at least, because i type ':t isAlpha' in GHCi and get 'variable not in 
scope'), so I created a module called CharClasses with these 
functions. So, I ran happy and generated calc.hs without any 

	When I try to compile calc.hs, by doing

	ghc -o calc.exe calc.hs CharClasses.hs

	I get:

undefined reference to `__stginit_Main'
undefined reference to `Main_main_closure'
undefined reference to `Main_main_closure' 

	I tried to compile each .o file separately, but I got the exact 
same errors. I don't know much about the structure of ghc and the 
interactions with gcc, but this does look like a linker error, and I'm 
guessing it's trying to tell me that I don't have a main function. But I 
do have one, as I checked the calc.hs and the

	main = getContents >> print . calc . lexer

	is there. GHCi seems to load the module just fine, and the 
parser and lexer seem to be working correctly. One strange thing 
that happens is that if I run an example from the interactive mode, 
it works, but if I call the main function, I get

*** Exception: calc.hs:285: Non-exhaustive patterns in function 

Another strange behavior is that I can only call the main function 
once. Any other call I get:

Happy> main
*** Exception: illegal operation
Action: hGetContents
Handle: {loc=<stdin>,type=semi-closed,binary=False,buffering=line}
Reason: handle is closed
File: <stdin>

	If I reload all modules with ':s' I can run it again, but also only 

	I really don't know what I'm doing wrong. Can anyone help me?

	Thank you in advance,