Haskell Introduction

Haskell is a general-purpose, purely functional programming language incorporating many recent innovations in programming language design.

Haskell provides higher-order functions, non-strict semantics, static polymorphic typing, user-defined algebraic datatypes, pattern-matching, list comprehensions, a module system, a monadic I/O system, and a rich set of primitive data types, including lists, arrays, arbitrary and fixed precision integers, and floating-point numbers.

Haskell is both the culmination and solidification of many years of research on lazy functional languages.

Haskell is lazy, which means that unless specifically told otherwise, Haskell won't execute functions and calculate things until it's really forced to show you a result. That goes well with referential transparency and it allows you to think of programs as a series of transformations on data.

C, Java, Pascal, Ada, and so on, are all imperative languages. They are "imperative" in the sense that they consist of a sequence of commands, which are executed strictly one after the other. Haskell is a functional language. A functional program is a single expression, which is executed by evaluating the expression.

Another interesting feature of functional languages like Haskell: functions are treated as values like integers (numbers) and strings. You can add a function to another function the way you can add an integer to an integer, 1 + 1, or 35 + 53.

Haskell programs are a series of high-level generalizable functions that define what the program is intended to do, letting lower layers (compiler, runtime, and libraries) handle mundane low-level details such as iteration. Its foundation is a strong static type safety and inference system.

The compiler enforces the type check and produces clean, concise, and correct code with few side effects from the outset.

Features of Haskell

  • Haskell is a purely functional programming language.
  • Referential transparency.
  • Haskell is lazy.
  • Programs as a series of transformations on data.
  • Haskell is statically typed
  • Haskell uses a very good type system that has type inference.
  • Haskell is elegant and concise.
  • Haskell was made by some really smart guys.
  • Haskell is a completely free language to use

Haskell Compiler

The Glasgow Haskell Compiler is a state-of-the-art, open-source compiler and interactive environment for the functional language Haskell.

The Glasgow Haskell Compiler (GHC) started as part of an academic research project funded by the UK government at the beginning of the 1990s.

Over its lifetime GHC has generally had around two or three active developers, although the number of people who have contributed some code to GHC is in the hundreds.

The Compiler

We can divide the compiler into three:

  • The compilation manager, which is responsible for the compilation of multiple Haskell source files.
  • The Haskell compiler (we abbreviate this as Hsc inside GHC), which handles the compilation of a single Haskell source file.
  • The pipeline, which is responsible for composing together any necessary external programs with Hsc to compile a Haskell source file to object code

Install Haskell

  • Go to the official download page :


  • Download the file based on your requirement, I am downloading Full
  • Open the downloaded exe file


  • Select the path for Haskell Installation
  • select-path-for-haskell-install
  • It will take a few minutes to complete the installation
  • progress-installation-haskell
  • On the completion of the installation, you might see a screen like the below image.


  • After installation, let's verify the installation. For that please open your cmd/terminal and type ghci command in the terminal, if you see output like the below one then your installation is successful.


Hello world in Haskell

It is a basic ritual kind of thing to write hello world in programming languages, so let's write hello world program in Haskell.

Prelude> "Hello, World!"
"Hello, World!"

The Haskell system evaluated the string and printed the result. Or we can try a variation to print directly to standard output:

Prelude> putStrLn "Hello World"
Hello World

Instead of running interactively, you can compile files to create an executable. The -o option lets you specify the name of the output file. The input file in this example is hello.hs, We can't just drop in a putStrLn call the way we would with something like Python. We have to define the main function.

When the program is run that will be the main entry point, just like all other languages. Here are the contents of hello.hs.

main = putStrLn "Hello, world!"

Compile it with

ghc -o hello hello.hs

Run the program

About Author :

I am Pavankumar, Having 8.5 years of experience currently working in Video/Live Analytics project.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions