Installing HBC

  1. The first step is, of course, to get a copy of the hbc compiler. The main ftp site is ftp://ftp.cs.chalmers.se/pub/haskell/chalmers.

    The naming structure of the files are like this:
    hbc-version.bin-arch-os.tar.gz
    where

    If there is no combination that suits your needs you are out of luck, but you can always try sending mail to hbc@cs.chalmers.se and ask for the status.

    There are code generators for the following architectures available: NS32k, M68K, I386, Alpha, ARM, Cray-1, HPPA, MIPS, PowerPC, RT/PC, SPARC, and Vax.

  2. Next, unpack the file you have fetched. Create a directory and do
        gunzip < the-file-you-fetched.tgz | tar xf -
        

  3. Then install the compiler.
        cd whereever-you-unpacked-it
        make BIN=platform install
        
    where platform corresponds to the arch-os part of the tar file you unpacked. This will install the executables in /usr/local/bin, the various other files in /usr/local/lib/lmlc and the man pages in /usr/local/man/man1.

    If you decide not to install the compiler in /usr/local/lib/lmlc you must set the environment variable HBCDIR to whatever directory you used instead to be able to compile.

  4. Send mail to hbc@cs.chalmers.se and say that you have installed a copy.

  5. Compile Haskell and enjoy(?).

Running Haskell

Here's some advice for those of you that don't have the patience to read the manual.

To run the interactive system just type hbi (NOTE: hbi doesn't work on all platforms). E.g.

  dogbert% hbi
  Welcome to interactive Haskell B. 1.4 version 0.9999.4 Pentium 1997 Feb 12!
  Loading prelude... 1559 values, 194 types found.
  Type "help;" to get help.
  > 1+2;
  3   

  > let inc x = x+1;;
  inc :: (Prelude.Num a) => a -> a
  > inc 6;
  7

  > asin (2 :+ 0);
  1.5707963267948966 :+ (-1.3169578969248166)

  > let fac 0 = 1
  #     fac n = n * fac(n-1)                        
  # ;
  fac :: (Prelude.Num a) => a -> a
  > fac 100;
  93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

  > whatis (+);
  method (+) :: (Prelude.Num b) => b -> b -> b
  > import Sort;
  Loading "/usr/local/lib/lmlc/hbc_library1.3/Sort.o"
  > whatis Sort;
  module Sort
    sortLe :: (b -> b -> Bool) -> [b] -> [b]
  > nub (sortLe (<=) "the quick brown fox jumps over the lazy dog");
  " abcdefghijklmnopqrstuvwxyz"

  > quit;
  Bye
  dogbert%

The compiler is called hbc. It has the about the same flags as ordinary UNIX compiler. If the file Main.hs contains

  main = putStr "ahoy, przygodo\n"
then it can be compiled and run by
  dogbert% hbc Main.hs
  dogbert% a.out | pol2eng
  hello, world
  dogbert%
To avoid having to keep track of dependencies and also writing Makefiles you should use hbcmake which figures out what has to be done automatically.
  dogbert% hbcmake Main
  hbc -c Main.hs
  hbc -o Main Main.o
  dogbert% Main
  ahoy, przygodo
  dogbert%

Recompiling the compiler

This is not necessary to just compile and run programs, but you may want to do it to prepare for future upgrades in the form of patches.

The first time you do this you have to do the following steps:

  1. Install the binaries as above, get and unpack the sources.
  2. cd src
  3. ./configure
    Answer the questions.
    You must answer what kind of system you have and what you want to build.
  4. make universe
    This will take quite a while. Any warnings from the C compiler may be ignored.
  5. If you want to make really sure that the new compiler is capable of recompiling itself, then run the script fixtst. This will recompile twice with successive new versions and compare them. THIS TAKES A LOT OF TIME!
  6. make install
    This will build and install the compiler and the libraries. THIS TAKES A LOT OF TIME!

Last modified: Thu Jan 30 12:41:22 MET 1997