
Hello merry Yhc'ers, Doing my homework for the upcoming Hac07 event, I installed and ran Yhc for the first time over some code that has so far survived both Hugs and GHC. In the spirit of Hac07, I downloaded Yhc and built it from the darcs repository, as described on http://haskell.org/haskellwiki/Yhc/Building. All this happened on a PPC Mac OS X 10.4 using a ghc-6.4.1 that I had installed earlier. I also had darcs installed already. Other tools scons, subversion, python24 (and perhaps more? I cannot recall) I took from darwinports. All this with surprisingly few stumbles. But I do have some comments and questions. And understand, please, that the answers may be perfectly obvious. And that none of these items are preventing anything important from happening. Nevertheless, it would help me a lot if some expert would take just a quick look through the list and say something about each. Feel free to simply say "Supply additional information", "Fix the documentation yourself", or "Report a bug" as appropriate. Here is the list: 1. I compile HelloWorld.hs by "yhc HelloWorld" and it works fine. However, in contrast to the description on http://haskell.org/haskellwiki/Yhc/Tutorial, the result is deposited in Main.hbc and Main.hi, so to run it, I must use "yhi Main". "yhi HelloWorld" produces a complaint (ERROR: couldn't find module named 'HelloWorld'). 2. When invoking yhc and also yhi, it seems that I can add a lot of different suffixes to the module name and they are simply ignored. Thus, "yhi Main.xxx" works just as well as "yhi Main". Throwing my input silently away like this seems unfriendly, I would much prefer to get an error message. 3. On http://haskell.org/haskellwiki/Yhc/Options and also in the output from "yhc -?", I find "-d -dst str destination path for generated bytecode files (default=.)". This dosen't seem right: I the cases I have tried, the bytecode was placed in the same directory as the source. And adding "-d something" did not seem to have any effect. 4. I also tried the command line yhe. However, I had to go into yhc/src/interactive and figure out myself how to build it. It hadn't been built as part of the "normal" build process. (I should mention that I am not particularly interested in the GUI yhe and probably don't even have the installments needed to build it.) 5. Getting to some more meaty things, actually compiling some code, I get the message "Error: Context for Prelude.Num needed in left hand pattern at 98:19-98:23." referring to this line in the code: (x,c) = prpExponent (n-1) p In ghci, I find that prpExponent :: (Num b, Integral a) => a -> a -> (a, b) If I add prpExponent :: Integer -> Integer -> (Integer,Int) (I sinfully avoid these type specifications in many cases), the module compiles fine. In another case of this: (p2p1f2,0) = divMod (p2+1) p2p1f1 yhc reports "Error: Context for Prelude.Integral needed in left hand pattern at 88:3-88:12.". For this, ghci reports p2p1f2 :: Integer p2 :: Integer p2p1f1 :: Integer and I can add p2 :: Integer to fix the problem. I have additional examples of this, all of them involving a pair as left hand side, some of them requiring more elaborate (but less obvious) repairs. Any comments? 6. I get the message "Nothing derived for Id 424 at nopos" and similar messages with 424 replaced by other numbers when a number of modules are compiled. The modules seem to compile OK, however. What does this mean? 7. I have only really managed to execute toy programs. For one of my "real" programs (also a toy, but you know what I mean), I get Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ yhi Primtal ERROR: couldn't find module named '_Builtin' tried: _Builtin.hbc /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/yhc-base/1.0/_Builtin.hbc Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ and I cannot figure out how to solve this problem. Other of my programs also complain that '_Builtin' is missing. 8. Compiling another program, I get Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ yhc -I EuclidNormal FcbMStep yhc: Error: File not found, Time Reason: imported from Main Looked in: /Users/thorkilnaur/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs/ . EuclidNormal /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/haskell98/1.0 /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/yhc-base/1.0 Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ I have done a very superficial investigation and it appears that it is certainly intended that Time should be included in the Yhc install. On the other hand, I cannot off hand find traces in the scons output that something related to Time has been built. I have similar problems with CPUTime. Please direct me. 9. Finally, I get a message "Error: Identifier getArgs used at 67:15-67:21 is not defined." when using that function in a Main module: args<-getArgs Please comment. Please complain if you think that I am wasting your time with trivia. I have been through most of the Wiki pages that I could find that were related to Yhc. I have also looked briefly over the bug list. Many thanks and best regards Thorkil

Hi
1. I compile HelloWorld.hs by "yhc HelloWorld" and it works fine. However, in contrast to the description on http://haskell.org/haskellwiki/Yhc/Tutorial, the result is deposited in Main.hbc and Main.hi, so to run it, I must use "yhi Main". "yhi HelloWorld" produces a complaint (ERROR: couldn't find module named 'HelloWorld').
GHC has the same behaviour, at least on Windows, producing main.exe always. I think if you pass the -hide option you'll get the correct name for the HelloWorld.hbc but it might be in the wrong place. We are currently not sure what to do about module name vs filename conflicts. I guess the short term fix is to update the docs, the long term fix is to make it produce a more logically named file.
2. When invoking yhc and also yhi, it seems that I can add a lot of different suffixes to the module name and they are simply ignored. Thus, "yhi Main.xxx" works just as well as "yhi Main". Throwing my input silently away like this seems unfriendly, I would much prefer to get an error message.
It used to be that yhc always required the .hs extension and that yhi never accepted an extension - that was really unfriendly :) That is a bug, Main should be interpreted as Main.hbc or Main, but no further than that.
3. On http://haskell.org/haskellwiki/Yhc/Options and also in the output from "yhc -?", I find "-d -dst str destination path for generated bytecode files (default=.)". This dosen't seem right: I the cases I have tried, the bytecode was placed in the same directory as the source. And adding "-d something" did not seem to have any effect.
Hmm, that seems weird. That sounds like a bug, I'll try and reproduce it later.
4. I also tried the command line yhe. However, I had to go into yhc/src/interactive and figure out myself how to build it. It hadn't been built as part of the "normal" build process. (I should mention that I am not particularly interested in the GUI yhe and probably don't even have the installments needed to build it.)
It's fallen out of focus, and was never great (it just shells out to yhc then yhi). It may not build anymore, but if it does scons build yhe would do it. The GUI was quite neat, but the requirements were an unreleased Gtk2Hs version. Once a Gtk2Hs version gets released we'll probably update it to work with that.
5. Getting to some more meaty things, actually compiling some code, I get the message "Error: Context for Prelude.Num needed in left hand pattern at 98:19-98:23." referring to this line in the code:
(x,c) = prpExponent (n-1) p
In ghci, I find that
prpExponent :: (Num b, Integral a) => a -> a -> (a, b)
If I add
prpExponent :: Integer -> Integer -> (Integer,Int)
(I sinfully avoid these type specifications in many cases), the module compiles fine. In another case of this:
(p2p1f2,0) = divMod (p2+1) p2p1f1
yhc reports "Error: Context for Prelude.Integral needed in left hand pattern at 88:3-88:12.". For this, ghci reports
p2p1f2 :: Integer p2 :: Integer p2p1f1 :: Integer
and I can add
p2 :: Integer
to fix the problem. I have additional examples of this, all of them involving a pair as left hand side, some of them requiring more elaborate (but less obvious) repairs. Any comments?
Sounds like an nhc bug that carried over. I'll open a bug report for it.
6. I get the message "Nothing derived for Id 424 at nopos" and similar messages with 424 replaced by other numbers when a number of modules are compiled. The modules seem to compile OK, however. What does this mean?
Never seen that before. Can you attach a module that gives this behaviour?
7. I have only really managed to execute toy programs. For one of my "real" programs (also a toy, but you know what I mean), I get
Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ yhi Primtal ERROR: couldn't find module named '_Builtin' tried: _Builtin.hbc /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/yhc-base/1.0/_Builtin.hbc Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$
and I cannot figure out how to solve this problem. Other of my programs also complain that '_Builtin' is missing.
Weird, I think Tom might have more idea what's going on here.
8. Compiling another program, I get
Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$ yhc -I EuclidNormal FcbMStep yhc: Error: File not found, Time Reason: imported from Main Looked in: /Users/thorkilnaur/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs/ . EuclidNormal /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/haskell98/1.0 /Users/thorkilnaur/tn/YhcDarcsRepository/yhc/inst/lib/yhc/packages/yhc-base/1.0
Thorkil-Naurs-Computer:~/tn/test/Yhc/HASKELL1/tn/Haskell/Hugs thorkilnaur$
I have done a very superficial investigation and it appears that it is certainly intended that Time should be included in the Yhc install. On the other hand, I cannot off hand find traces in the scons output that something related to Time has been built. I have similar problems with CPUTime. Please direct me.
Maybe the build script is missing them. I've never tried to work with Time or CPUTime. I'll try and figure out whats going on there.
9. Finally, I get a message "Error: Identifier getArgs used at 67:15-67:21 is not defined." when using that function in a Main module:
args<-getArgs
Have you got import System.Environment? or import System? It's possible that one of them is lacking a reexport of getArgs. I've certainly used getArgs in a Yhc program before.
Please complain if you think that I am wasting your time with trivia.
On the contarary. This has been very helpful! If you look through the bug list tomorrow you'll see all these issues on it :) See you at Hac07 Neil

"Neil Mitchell"
1. I compile HelloWorld.hs by "yhc HelloWorld" and it works fine. However, in contrast to the description on http://haskell.org/haskellwiki/Yhc/Tutorial, the result is deposited in Main.hbc and Main.hi, so to run it, I must use "yhi Main". "yhi HelloWorld" produces a complaint (ERROR: couldn't find module named 'HelloWorld').
GHC has the same behaviour, at least on Windows, producing main.exe always.
And this behaviour was equally annoying under ghc! It was widely regarded as a bug, and I'm glad to say it is now fixed with ghc-6.6.
5. Getting to some more meaty things, actually compiling some code, I get the message "Error: Context for Prelude.Num needed in left hand pattern at 98:19-98:23."
Sounds like an nhc bug that carried over. I'll open a bug report for it.
Yep, it is an old bug, noted for ages on the nhc98 webpages. It has something to do with the (lack of the) monomorphism restriction. Regards, Malcolm

Hello, On Saturday 06 January 2007 12:47, Neil Mitchell wrote:
...
6. I get the message "Nothing derived for Id 424 at nopos" and similar messages with 424 replaced by other numbers when a number of modules are compiled. The modules seem to compile OK, however. What does this mean?
Never seen that before. Can you attach a module that gives this behaviour?
Here is one, very small so I refrain from attaching: module Id424 where f x = xd2 where (xd2,0) = x`divMod`2 This is what it looks like when I compile it: Thorkil-Naurs-Computer:~/tn/test/Yhc/Id424 thorkilnaur$ yhc Id424 Compiling Id424 ( Id424.hs ) Nothing derived for Id 207 at nopos Thorkil-Naurs-Computer:~/tn/test/Yhc/Id424 thorkilnaur$ Bytecode is produced.
...
9. Finally, I get a message "Error: Identifier getArgs used at 67:15-67:21 is not defined." when using that function in a Main module:
args<-getArgs
Have you got import System.Environment? or import System? It's possible that one of them is lacking a reexport of getArgs. I've certainly used getArgs in a Yhc program before.
I had import System. Changing to import System.Environment removed the complaint. Thanks.
... This has been very helpful!
Very satisfying, thanks. Best regards Thorkil
participants (3)
-
Malcolm Wallace
-
Neil Mitchell
-
Thorkil Naur