Programming Languages Section

What about Haskell ?

Card image
Post by Amina Delali, October 28th, 2021

Some Facts

Haskell is a purely functional programming language, where there are no instructions but only expressions that do not mutate variables. Statically typed but also supports type inference, the language can be used in a wide variety of real world domain applications: aerospace, defence, finance ... etc.

Haskell is a general purpose programming language so you can use it in different types of applications: network programming, GUI applications, databases and web client developments, system programming .. etc.



How to install it

    To be able to use Haskell , you will have to install the Haskell Platform

  • on Windows:
    1. First you will have to install chocolatey , the windows package manager. To do this, you will have to follow these instructions:
      1. run the powershell as an Administrator.
      2. Run the command:  Get-ExecutionPolicy If it returns Restricted, then run Set-ExecutionPolicy AllSigned command
      3. Run the command that will install Chocolatey: Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
    2. to install the Haskell Platform, use the following command ( with administrator privileges): choco install haskell-dev
      refreshenv
  • on ubuntu :

    Simply run the following commands:

    $ sudo apt update
    $ sudo apt install haskell-platform

The Hello World Example

  1. Hello world in haskell:

    1. create a new file in the home folder and save it under the the name hello.hs
    2. in the file write and save the following code:

    main :: IO ()
    main putStrLn ("Hello World!")

    1. Now, you will have to compile your code. To do that, just open your terminal and write the following command:
    $ ghc hello.hs
    1. now, you can run your code, by typing the next command in your terminal:
    $ ./hello


Something to say ?

If you want to add something about the language or about this post, please feel free to do it by commenting below 🙂 .