lunduniversity.lu.se

Computer Science

Faculty of Engineering, LTH

Denna sida på svenska This page in English

EDAN40 Programming Environment

This text is expected to be accurate at this moment (28th October 2015). Please let me know (JM) in case of any issues.


Regarding System.Random and Test.HUnit problems, here comes a short help from Linus:

Installing Haskell packages:

On your own computer, the easiest way is probably to install Cabal first. Get it from the same place you got GHC. Then you type "cabal update" followed by e.g. "cabal install random" to get the random package.

On the school computers (*.student.lth.se), cabal is not present. We will try to fix this. In the meantime, you can manually install the random package by issuing the following commands in a terminal window. You can ignore warnings about Tab characters.

For the System.Random module:

mkdir temp

cd temp

wget hackage.haskell.org/package/random-1.1/random-1.1.tar.gz

tar zxf random-1.1.tar.gz

cd random-1.1

runhaskell Setup configure --user

runhaskell Setup build

runhaskell Setup install

cd ../..

rm -rf temp

 

and for the Test.HUnit module:

mkdir temp

cd temp

wget hackage.haskell.org/package/HUnit-1.3.0.0/HUnit-1.3.0.0.tar.gz

tar zxf HUnit-1.3.0.0.tar.gz

cd HUnit-1.3.0.0

runhaskell Setup configure --user

runhaskell Setup build

runhaskell Setup install

cd ../..

rm -rf temp

The packages have now been installed locally in your home directory, and are hiding inside the ".ghc" and ".cabal" subdirectories.


For all programming exercises and assignments you will use GHCi, the interpreter part of the Glasgow Haskell Compiler system. You may need to access the user manual.

You can install GHC and GHCi on your own computer from here (pointer to the exact version we use, 7.10.2). Test your installation by creating a new file Test.hs containing the code

module Main where

main = putStrLn "Hello, world!"

Load the file and type main at the GHCi prompt. You should get the response "Hello, world!".

To use GHCi on the Linux student systems just type ghci at the prompt. You should get version 7.10.2 of ghc. (You may need to set your path to /opt/ghc/7.10.2/bin, either by saying initcs or some other way.)

Editing Haskell files can be done by any text editor. For those favouring Emacs there is a haskell-mode which automatically handles indentation and syntax colouring. There is also a haskell mode definition for the Vim editor.