Cyberithub

How to Install Haskell Platform on Ubuntu 20.04 LTS

Advertisements

In this article, I will take you through the steps to install Haskell platform on Ubuntu 20.04 LTS. Haskell is a general purpose, purely functional programming language which has been around for quite sometime. The Haskell Platform is a collection of software packages, tools and libraries that create a common platform for using and developing applications in Haskell. The best and recommended way to start with Haskell Programming is through Haskell Platform. So we need to first install the Haskell platform first really starting with the Haskell programming. More on Haskell Documentation.

How to Install Haskell Platform on Ubuntu 20.04 LTS

How to Install Haskell Platform on Ubuntu 20.04 LTS

Also Read: How to Install Racket Programming Language on Ubuntu 20.04 LTS

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS System.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility installed in the Server.

 

Step 2: Update Your System

It is always recommended to check if there are any new versions of your installed packages are available to download and install using apt update or apt-get update command. This will make sure all the installed packages from all the repositories are up to date.

root@localhost:~# apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Hit:4 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
Hit:5 https://apt.releases.hashicorp.com focal InRelease
Hit:6 https://packages.microsoft.com/repos/edge stable InRelease
Hit:7 http://ppa.launchpad.net/micahflee/ppa/ubuntu focal InRelease
Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [283 kB]
Hit:11 https://packages.grafana.com/oss/deb stable InRelease
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [362 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B]
Get:14 http://in.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [10.4 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [29.0 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [63.7 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,468 B]

 

Step 3: Install Haskell Platform

In the next step, you need to install Haskell Platform by using apt-get install haskell-platform -y command as shown below.

root@localhost:~# apt-get install haskell-platform -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
alex cabal-install freeglut3 freeglut3-dev ghc happy hscolour libbsd-dev libegl-dev libffi-dev libghc-async-dev libghc-attoparsec-dev
libghc-call-stack-dev libghc-case-insensitive-dev libghc-erf-dev libghc-fgl-dev libghc-fixed-dev libghc-gluraw-dev libghc-glut-dev libghc-half-dev
libghc-hashable-dev libghc-haskell-src-dev libghc-html-dev libghc-http-dev libghc-hunit-dev libghc-integer-logarithms-dev libghc-network-dev
libghc-network-uri-dev libghc-objectname-dev libghc-opengl-dev libghc-openglraw-dev libghc-parallel-dev libghc-primitive-dev libghc-quickcheck2-dev
libghc-random-dev libghc-regex-base-dev libghc-regex-compat-dev libghc-regex-posix-dev libghc-scientific-dev libghc-split-dev libghc-statevar-dev
libghc-syb-dev libghc-tf-random-dev libghc-unordered-containers-dev libghc-vector-dev libghc-zlib-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1
libglu1-mesa-dev libglvnd-dev libglx-dev libgmp-dev libgmpxx4ldbl libncurses-dev libncurses5-dev libopengl-dev libopengl0 libxext-dev libxfixes-dev
libxi-dev libxmu-dev libxmu-headers x11proto-input-dev x11proto-xext-dev zlib1g-dev
........................................................................................

 

Step 4: Check Haskell Compiler Version

Once the platform is installed successfully, you can check the Haskell Compiler version by using haskell-compiler --version command.

root@localhost:~# haskell-compiler --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

 

Step 5: Start Haskell

After installing Haskell Platform, you can now start GHC Interpreter by running ghci command on the ubuntu terminal as shown below.

root@localhost:~# ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude>

 

Step 6: Write Your First Haskell Program

You can now write your first haskell program where you can display a simple statement on the output as shown below.

root@localhost:~# ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude> "Hi, This is from CyberITHub"
"Hi, This is from CyberITHub"
Prelude>

Alternatively, you can also write your program like below where you can create a file called example.hs with our favorite nano text editor and add below contents to just display Hi, This is from CyberITHub !! on the output. Then save and close the file by Pressing Ctrl+X.

root@localhost:~# nano example.hs
main = putStrLn "Hi, This is from CyberITHub !!"

Compile Your Program

root@localhost:~# ghc -o example example.hs
[1 of 1] Compiling Main ( example.hs, example.o )
Linking example ...

Run Your Program

root@localhost:~# ./example
Hi, This is from CyberITHub !!

 

Step 7: Remove Haskell Platform

Once you are done with Haskell Platform, you can remove it completely by using apt-get remove haskell-platform -y command as shown below.

root@localhost:~# apt-get remove haskell-platform -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
alex cabal-install freeglut3 freeglut3-dev ghc happy hscolour libbsd-dev libegl-dev libffi-dev libghc-async-dev libghc-attoparsec-dev
libghc-call-stack-dev libghc-case-insensitive-dev libghc-erf-dev libghc-fgl-dev libghc-fixed-dev libghc-gluraw-dev libghc-glut-dev libghc-half-dev
libghc-hashable-dev libghc-haskell-src-dev libghc-html-dev libghc-http-dev libghc-hunit-dev libghc-integer-logarithms-dev libghc-network-dev
libghc-network-uri-dev libghc-objectname-dev libghc-opengl-dev libghc-openglraw-dev libghc-parallel-dev libghc-primitive-dev libghc-quickcheck2-dev
libghc-random-dev libghc-regex-base-dev libghc-regex-compat-dev libghc-regex-posix-dev libghc-scientific-dev libghc-split-dev libghc-statevar-dev
libghc-syb-dev libghc-tf-random-dev libghc-unordered-containers-dev libghc-vector-dev libghc-zlib-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1
libglu1-mesa-dev libglvnd-dev libglx-dev libgmp-dev libgmpxx4ldbl libncurses-dev libncurses5-dev libopengl-dev libopengl0 libxext-dev libxfixes-dev
libxi-dev libxmu-dev libxmu-headers x11proto-input-dev x11proto-xext-dev zlib1g-dev
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
haskell-platform
0 upgraded, 0 newly installed, 1 to remove and 8 not upgraded.
After this operation, 12.3 kB disk space will be freed.
(Reading database ... 244903 files and directories currently installed.)
Removing haskell-platform (2014.2.0.0.debian8) ...

2 thoughts on “How to Install Haskell Platform on Ubuntu 20.04 LTS”

Leave a Comment