IA014 Advanced Functional Programming

Haskell Notes

Installing Haskell

There are many ways to install Haskell - both the compiler (GHC) and libraries. I personally use The Haskell Tool Stack. For Linux, I would prefer the newest original packages, rather than using those included in your distribution.  For Windows, The Haskell Tool Stack webpage includes a nice installer.

Which version of  GHC?

In the lectures I use  and Stackage LTS 15.5 packages. If you use the Haskell Tool Stack, this is what you get by default. All code provided is tested to work with this setup. 

For monad and monad transformer code to work correctly you need to install the mtl library.

Where to find information on packages etc.?

Use the search provided by Stackage.

To get the monad transformers source codes to work, you need to install the mtl library.

Which IDE?

It is totally up to you, you should be fine with a plain command line. I personally use Emacs and the Haskell mode. I also find the Interactive Haskell feature quite handy.

Some useful GHCi commands?

Sure, here you go:
:browse[!] [[*] ⟨module⟩]

Displays the identifiers exported by the module ⟨module⟩, which must be either loaded into GHCi or be a member of a package. If ⟨module⟩ is omitted, the most recently-loaded module is used.
 

:info[!] ⟨name⟩

Displays information about the given name(s). For example, if ⟨name⟩ is a class, then the class methods and their types will be printed; if ⟨name⟩ is a type constructor, then its definition will be printed; if ⟨name⟩ is a function, then its type will be printed. If ⟨name⟩ has been loaded from a source file, then GHCi will also display the location of its definition in the source.

:kind[!] ⟨type⟩

Infers and prints the kind of ⟨type⟩

:type ⟨expression⟩

Infers and prints the type of ⟨expression⟩, including explicit forall quantifiers for polymorphic types.

The commands above can be shortened to :bro, :i, :k, and :t respectively.
To print the explicit "forall" quantifiers, use :set -fprint-explicit-foralls
The full documentation can be found here.

Do I need to actually run Haskell to pass the course?

No, you do not. But playing around with Haskell and trying out the concepts covered in the lectures helps a lot.