[Yhc] Yhc: A first impression

Neil Mitchell ndmitchell at gmail.com
Sat Jan 6 06:47:20 EST 2007


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


More information about the Yhc mailing list