YHC build finished successfully, but install is not "fairly trivial"

Hello all, I just 'darcs got' the sources and compiled YHC on Linux (Ubuntu) last night. I got it to compile just fine with 'make' but on the install side of things I ran into a number of problems. I read on the wiki (YHC/Building) that
There currently isn't a 'make install', but it is fairly trivial: simply copy the contents of the 'inst' directory into where everything should be installed.
I didn't find this to be the case. I copied the 'inst' folder to '/usr/lib/yhc', but then (1) I had to set up an environment variable YHC_BASE_PATH to point there, (2) I had to symlink 'yhi' and 'yhc' to '/usr/bin'. That really wasn't that big of a deal. I ran YHC on a test Haskell script, called Main.hs:
module Main (main) where
fac 0 = 1 fac n | n > 0 = n * fac (n-1)
main = print $ fac 30
and it succeeds. But, trying to run the .hbc file with yhi fails: -------- ERROR: couldn't find module named 'Data/Ratio' tried: Data/Ratio.hbc /usr/lib/yhc/lib/yhc/packages/yhc-base/1.0/Data/Ratio.hbc -------- In that directory, there exist a bunch of .hbc and .hi file pairs (Char, Array, List, Ix, Complex, Maybe, PackedString, _CharNumeric) , AND Ratio.hi, but no Ratio.hbc ..., (incidentally, /usr/lib/yhc/lib/yhc/packages/haskell98/1.0/Ratio.hbc DOES exist...) The question is, why does running my factorial program trigger a Data.Ratio error? I think it's an installation problem, and it's probably related to the fact that... ... I can't really get most of the test suite to run. (Here is a link to the error output stream of runtests.py: http://www.updike.org/~jared/here/err.txt (164kB)) This is not "fairly trivial", this is disheartening. What am I missing? I will update the wiki when I get it working, if I can get some help with the path and directory scheme, environment variables, and other black magic. Jared. P.S. I am still really excited about YHC! -- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

I went over the archive at
http://www.haskell.org/pipermail/yhc/2005-December.txt (for some
reason my message didn't copy itself and I'm hoping yhc@haskell.org
sends this to me correctly so sorry if this message is not really
asking a question) and found the solution. It was as simply as copying
src/yhc/bootstrap/packages/yhc-base/1.0/Data/Ratio.hbc
to
/usr/lib/yhc/lib/yhc/packages/yhc-base/1.0/Data/
I imagine this all has to do with the way that yhi loads more than
just the Prelude before interpreting the hbc file? My guess is that
YHI has two modes and that by default it is running in "hierarchical
library mode" which is a superset of haskell-98 (but uses a different
package), which means it includes more than just the Prelude to do any
normal task? That also explains why yhc/lib/yhc/packages has yhc-base/
and haskell98/ with what looks like similar files with different file
hierarchy (i.e h98 = flat, yhc-core = hierarchical).
Cheers,
Jared.
On 12/21/05, Jared Updike
Hello all,
I just 'darcs got' the sources and compiled YHC on Linux (Ubuntu) last night. I got it to compile just fine with 'make' but on the install side of things I ran into a number of problems.
I read on the wiki (YHC/Building) that
There currently isn't a 'make install', but it is fairly trivial: simply copy the contents of the 'inst' directory into where everything should be installed.
I didn't find this to be the case. I copied the 'inst' folder to '/usr/lib/yhc', but then (1) I had to set up an environment variable YHC_BASE_PATH to point there, (2) I had to symlink 'yhi' and 'yhc' to '/usr/bin'.
That really wasn't that big of a deal. I ran YHC on a test Haskell script, called Main.hs:
module Main (main) where
fac 0 = 1 fac n | n > 0 = n * fac (n-1)
main = print $ fac 30
and it succeeds. But, trying to run the .hbc file with yhi fails: -------- ERROR: couldn't find module named 'Data/Ratio' tried: Data/Ratio.hbc /usr/lib/yhc/lib/yhc/packages/yhc-base/1.0/Data/Ratio.hbc -------- In that directory, there exist a bunch of .hbc and .hi file pairs (Char, Array, List, Ix, Complex, Maybe, PackedString, _CharNumeric) , AND Ratio.hi, but no Ratio.hbc ..., (incidentally, /usr/lib/yhc/lib/yhc/packages/haskell98/1.0/Ratio.hbc DOES exist...)
The question is, why does running my factorial program trigger a Data.Ratio error? I think it's an installation problem, and it's probably related to the fact that...
... I can't really get most of the test suite to run. (Here is a link to the error output stream of runtests.py: http://www.updike.org/~jared/here/err.txt (164kB))
This is not "fairly trivial", this is disheartening. What am I missing? I will update the wiki when I get it working, if I can get some help with the path and directory scheme, environment variables, and other black magic.
Jared.
P.S. I am still really excited about YHC!
-- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"
-- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

Hi Jared,
(1) I had to set up an environment variable YHC_BASE_PATH to point there Yes, YHC_BASE_PATH is an ugly wart in the YHC compiler, we're going to do some work to try and remove it, or at least make it required less often. Ideally it should "guess" where your base path is, and YHC_BASE_PATH should only be for people who want to put it somewhere weird. YHC_BASE_PACKAGE should point at the inst directory. Its used so the compiler and runtime can find the Haskell packages.
The question is, why does running my factorial program trigger a Data.Ratio error? Because you used numbers, that requires Data.Ratio. If your program had been putStrLn "hello world" then this wouldn't have happened. Its unfortunate that particular .hbc file is not copied by the makefile - thats a bug in the makefile! For now just manually copy the Ratio.hbc over.
... I can't really get most of the test suite to run. (Here is a link to the error output stream of runtests.py: http://www.updike.org/~jared/here/err.txt (164kB)) The python script is now depreciated, in src/tester there is a new Haskell testing script. No one has yet run it from Unix, but its built on Windows.
Your test report isn't that bad - the latest windows version gives this: http://www-users.cs.york.ac.uk/~ndm/yhc/report.html - you can see there are still quite a lot of failures. Most of those problems are pretty trivial - missing modules and other small things. We will probably have a good go at reducing the regression test errors to 0 in January sometime. btw, your emails both sent to the list successfully. With regards to your comments about flat vs heirarchical: The original flat module space is defined in the Haskell 98 report, and used by lots of Haskell programs. Since that time, Heirarchical modules were introduced which include lots of additional functionality. yhc-base is the standard modules for Yhc, and these do most of the work. The flat module structure is retained for compatability with programs using the Haskell98 module structure, most of these just import the appropriate heirarchical module and re-export stuff.
P.S. I am still really excited about YHC! Good :) I hope we can get you through these little glitches! If you have anymore questions just send an email off to us.
Thanks Neil

Great. Thanks for the response. I'm able to run programs with yhi now! Maybe I can help with testing on Unix (Linux), plus I have a Windows machine and MS VS so I will try compiling on Windows for good measure. BTW I added some notes to the YHC/Building wiki about YHC_BASE_PATH, copying Data/Ratio.hbc, and how things are in flux. Crazy Idea: ----------------- I have a slightly ambitious idea but I think it could really rock. I haven't worked through all the subtleties yet, but basically I would love to see Haskell deployable in //the most// widely portable platform ever: the browser. My crazy idea: port the YHC runtime to JavaScript! It's so crazy it just might work. I figure if people ported it to Python and Java, why not go for the gold and get it deployable on any machine! The truth is, I was thinking about how to compile Haskell to JavaScript for the last few weeks, and I was sort of intimidated at the idea of even starting hacking the GHC RTS or writing a GHC backend... but then I heard about YHC, and how it compiles to a clean, small bytecode with a carefully separated VM/RTS and now it's actually a possibility. It makes really small binaries (.HBC), it looks like: hundreds of bytes, in the size range of Python .PYC files. These could //definitely// be embedded into a webpage. I would really love to be able to write dynamic webpages in Haskell (totally natively, i.e. no combinator library or special embedded language, but in actual Haskell 98!), or be able to run a Haskell interpreter in a web browser for people to play with (e.g. on Haskell.org), to make the best interactive learning tool / tutorial---all without the website visitor having to download anything or even think about that! Cheers, Jared. -- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

Hi Jared,
BTW I added some notes to the YHC/Building wiki about YHC_BASE_PATH, copying Data/Ratio.hbc, and how things are in flux. Thanks!
Crazy Idea: ----------------- I have a slightly ambitious idea but I think it could really rock. I haven't worked through all the subtleties yet, but basically I would love to see Haskell deployable in //the most// widely portable platform ever: the browser. My crazy idea: port the YHC runtime to JavaScript! It's so crazy it just might work. I figure if people ported it to Python and Java, why not go for the gold and get it deployable on any machine!
The truth is, I was thinking about how to compile Haskell to JavaScript for the last few weeks, and I was sort of intimidated at the idea of even starting hacking the GHC RTS or writing a GHC backend... but then I heard about YHC, and how it compiles to a clean, small bytecode with a carefully separated VM/RTS and now it's actually a possibility. It makes really small binaries (.HBC), it looks like: hundreds of bytes, in the size range of Python .PYC files. These could //definitely// be embedded into a webpage.
I would really love to be able to write dynamic webpages in Haskell (totally natively, i.e. no combinator library or special embedded language, but in actual Haskell 98!), or be able to run a Haskell interpreter in a web browser for people to play with (e.g. on Haskell.org), to make the best interactive learning tool / tutorial---all without the website visitor having to download anything or even think about that!
Thats a cool idea! Also, because Yhc is written in Haskell and can be compiled to an HBC file, you could even run the compiler in the browser (although probably quite slowly). There is an interpreter being written in Python, and there is one written in Java, so they would probably be a better starting point than the C runtime. The Java one is on the web (http://www.brianweb.net/personal/blog/entry.php?id=18), but the python one is still in development. Documentation on various stuff is available at: http://www.haskell.org/hawiki/Yhc_2fRTS http://www-users.cs.york.ac.uk/~ndm/yhc/bytecodes.html You would probably want to write a hbc -> Javascript convertor in a language that wasn't Javascript, probably in Haskell. I recommend using: http://www.haskell.org//pipermail/yhc/2005-November/000004.html Then write a Javascript interpeter for the instructions. Thanks, and good luck - just ask any further questions. Neil

Thats a cool idea! Also, because Yhc is written in Haskell and can be compiled to an HBC file
This is a *huge* plus! That is so wicked cool. Ha! I'm giddy!
you could even run the compiler in the browser (although probably quite slowly).
I was thinking that too, especially for teaching Haskell (online, interactive, no downloading anything!)
There is an interpreter being written in Python, and there is one written in Java, so they would probably be a better starting point than the C runtime. The Java one is on the web (http://www.brianweb.net/personal/blog/entry.php?id=18), but the python one is still in development.
Do you know who is working on the Python interpreter? I could get in touch with them. I think Python is the most similar to JavaScript anyway (dynamic typing, everything an object). Plus I'm a lot more fluent in Python than Java (and of course I enjoy it more). But I bet both will help.
Documentation on various stuff is available at: http://www.haskell.org/hawiki/Yhc_2fRTS http://www-users.cs.york.ac.uk/~ndm/yhc/bytecodes.html
Thanks for the refs!
You would probably want to write a hbc -> Javascript convertor
I also thought this would be a good idea. Ultimately you want a program that takes an hbc file and gives you an HTML file that you plop on the web and just use (pointing to or embedding the RTS JavaScript core for you.)
in a language that wasn't Javascript
Also smart.
probably in Haskell.
Oh, that's a good idea, hadn't thought of that ;-)
I recommend using: http://www.haskell.org//pipermail/yhc/2005-November/000004.html
Definitely a great place to get started. Plus any improvements on my end can go back into this API. :-)
Then write a Javascript interpeter for the instructions.
This is the hard part (I don't know anything about JavaScipt IDEs but I suspect debugging will be ... interesting). Maybe that's a good place to start out... looking for a good IDE for JavaScript. <wondering out loud>I wonder if Visual J# is a reasonable choice (already installed on my system) or is this a dangerous place to go...</wondering>
Thanks, and good luck - just ask any further questions.
Great. I probably will. Hopefully soon. Merry Christmas and Happy New Year, and thanks again for everything! Jared. -- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

Hi Jared,
There is an interpreter being written in Python, and there is one written in Java, so they would probably be a better starting point than the C runtime. The Java one is on the web (http://www.brianweb.net/personal/blog/entry.php?id=18), but the python one is still in development.
Do you know who is working on the Python interpreter? I could get in touch with them. I think Python is the most similar to JavaScript anyway (dynamic typing, everything an object). Plus I'm a lot more fluent in Python than Java (and of course I enjoy it more). But I bet both will help.
The person working on the Python one is Andrew Wilkinson, http://www-users.cs.york.ac.uk/~aw/ - he'll certainly have his python version in the darcs after new years, but if you email him he might be able to give you what he's got so far.
You would probably want to write a hbc -> Javascript convertor
I also thought this would be a good idea. Ultimately you want a program that takes an hbc file and gives you an HTML file that you plop on the web and just use (pointing to or embedding the RTS JavaScript core for you.) Since Haskell compiles to modules, and each module is a separate .hbc file, you might want to have a single .js for each module and then an HTML file that just does <script src="file.js"> for each javascript module.
Definitely a great place to get started. Plus any improvements on my end can go back into this API. :-) The API is going to be massively improved - the ultimate idea is to write a really good bytecode library, and then have the compiler use that one, so people can easily write utilities that operate on .hbc files. The library as it stands today has a pretty printer in it, tweaking that will probably give you the Javascript output you need without too much difficulty.
Then write a Javascript interpeter for the instructions.
This is the hard part (I don't know anything about JavaScipt IDEs but I suspect debugging will be ... interesting). If you are using Firefox or Mozilla, then Venkmann is a competent enough debugger - its available as an extension - google for it because it usually doesn't show up in teh Firefox extensions list.
Maybe that's a good place to start out... looking for a good IDE for JavaScript. <wondering out loud>I wonder if Visual J# is a reasonable choice (already installed on my system) or is this a dangerous place to go...</wondering> J# is Microsofts version of Java, stay well clear! However, they do have JScript, which is Microsoft's version of Javascript, and that may work in the same IDE, if you have the right options installed.
My personal choice of Javascript IDE is Visual Interdev, but that got discountinued some time ago - most of the functionality should be in Visual Studio .NET, but I've never checked. Merry Christmas to you too, Neil
participants (2)
-
Jared Updike
-
Neil Mitchell