Instructions for Running MicroHaskell Programs on Unix Machines in the Undergraduate Lab
--------------------------------------------------------------------------------
Procedures to Run MicroHaskell Programs on Unix in the Undergraduate Lab
1. Access your account by your Unix User name and password
2. Open the Command Prompt
3. Create a MicroHaskell program and save as a file
Type a text command such as "pico" or "vi" to edit your MicroHaskell program under command prompt.
For example, enters "pico test1.hs". This step creates/opens a
MicroHaskell file called "test1"
with the extension "hs". Note : every MicroHaskell source file ends with
"hs". Please note that the layout
of your MicroHaskell program affects
the correctness of your syntax. (Sometimes your program obeys the EBNF of
MicroHaskell. But if your layout is not appropriate, the compiler will show syntax
errors.) For more information, please refer to www.haskell.org.
4. Load and compile your MicroHaskell program:
After saving source code by command "Ctrl+x" for pico, the next step is loading and compiling your code.
Under the same directory of your MicroHaskell program, type "/usr/local/bin/hugs".
The MicroHaskell compiler (same as Haskell compiler) will be invoked. Load
your program by ":load test1". If your program has any syntax error,
there will be syntax error message shows you what the problems may be.
5. Run the MicroHaskell program
After you load and compile your MicroHaskell program successfully, you can run it:
type "test1" on the command line to run it. ("test1" is the
ID (left hand side) on the first line of your program)
---------------------------------------------------------------------------------
Example
blazer5[liush](78)%pico test1.hs
{- source code for test1 written in MicroHaskell -}
test1 = (12 * 3 + 5 ) + head(tail(3:5:[]))
{- Please remember layout of the program matters -}
blazer5[liush](86)% hugs
{- Invoke Haskell compiler -}
__ __ __ __ ____ ___ _________________________________________
|| || || || || || ||__ Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__|| __|| Copyright (c) 1994-2003
||---|| ___|| World Wide Web: http://haskell.org/hugs
|| || Report bugs to: hugs-bugs@haskell.org
|| || Version: November 2003 _________________________________________
Haskell 98 mode: Restart with command line option -98 to enable extensions
Type :? for help
Prelude> :load test1 {- Load test1.hs.
Because there is no syntax error, so no error message will show up here -}
Main> test1
{- Run your MicroHaskell program."test1" is the ID on the first line
of the program -}
46
{- Result of test1.hs -}
Main>