Installing Haskell
To run Haskell code, you need a Haskell compiler. The Glasgow Haskell Compiler (GHC) is the official implementation of the Haskell platform. You have a couple of options to get ahold of GHC: install it on your local machine or log in to a departmental server.
Having Haskell on your own computer has advantages: you're not relying on a clumsy internet connection, files can be manipulated using your operating system's file explorer, and you can install third-party packages. Install it with GHCup.
Using a server with Haskell already installed also has advantages: you don't have to deal with permissions issues, and you don't waste time waiting for the platform to download and compile. Haskell is already installed on stu
, and you don't need to do anything special to make it work. Just log in to stu
with your favorite SSH client or SSH-powered editor.
Once you have access to GHC, run a Haskell program from the command line like this:
runhaskell path/to/my/script.hs
If you want to run Haskell code interactively, run ghci
like this:
ghci
Use :l script.hs
to load functions and variables from a file in the current directory. If you make modifications to the file, reload it with :r
.