The HBI interactive system
Using hbi
The interactive system can load both source
files and compiled files. Functions defined with the interactive
system runs 10 -- 50 times slower than compiled code; compiled code
called from interactive use runs at full speed.
The system is started by
hbi
and you will then be greeted by (something like)
Welcome to interactive Haskell B. 1.4 version 0.9999.4 Pentium 1997 Feb 12!
Loading prelude... 1457 values, 199 types found.
Type "help;" to get help.
>
The interactive version of Haskell B uses dynamic loading of object files,
since this is rather complicated for some machines it has not been
implemented for all platforms yet.
Commands
The first prompt is ``>'' and any subsequent prompts until a command
is completed will be ``#''.
The following commands are available (note that they all end with semicolon):
- expression;
Evaluate and print the expression (more on printing below).
- let decl;
Make the bindings in decl and make them available in
the rest of the session. No evaluation of the bound objects
is performed. The usual offside rule applies here.
- ident <- expression;
The expression must be of type IO t. The I/O action is
performed and the identifier gets the resulting value.
- topdecl;
Any top level declaration except decl.
- load "file";
Load a file. The string specifies what should be loaded, it can have
three forms:
- *.hs
load a .hs file. This must be an ordinary Haskell B module.
- *.o
load .o and .hi files. These files must be produced
by compiling an ordinary Haskell B module with hbc.
- *
loads *.hs if it is newer than *.o, otherwise the *.o file.
- import moduleid;
Load a .o file using the $HBCINCPATH, used to load library stuff.
- source "file";
Read commands from the given file.
- whatis ident;
Give information about the identifier ident.
- help;
Print some information about hbi.
- quit;
Quit the system.
The defaults for numeric types are Integer and Double
instead of Int and Double in the compiler.
(This is nicer when hbi is used as a calculator.)
It is possible to interrupt the evalution of an expression by hitting
the interrupt key.
If the program does not stop after the first at first try, then wait a little and try again.
The first only interrupts the program at certain well defined places
and is less dangerous. The second stops the program anywhere except in
garbage collection.
There is an tcsh/Emacs like command line editing available.
The system catches most errors and prints an appropriate message.
Unfortunately some errors, like stack overflow, may be uncaught and
the system just dies.
Printing
If the value to be printed is of type IO () the I/O action is
performed and nothing is printed. If it is of type IO t the
I/O action is performed and the resulting value is printed by first
applying show to it. All other values are printed by
applying show and printing the resulting string.
During garbage collection the string `` GC '' will occur on the output.
Shared object loading
On some systems, hbi cannot load object code from .o files, but use
shared objects (.so files) instead. When loading or importing
files compiled by the user, hbi will automatically build and use such
shared objects. On these systems, hbi will also look for shared
libraries named lib_i.so or lib.so in $HBCINCPATH
when importing library modules.
On systems which allow both normal and shared object loading, hbi
defaults to normal loading. Shared object loading can then be achieved
by starting hbi with ``-s''.
Compiling with hbc for use by hbi
If shared object loading is used, compile with the flag ``-fno-zap-redex''.
Last modified: Thu Jan 30 12:38:23 MET 1997