Friday, 29 April 2016

Setting up Haskell in your machine

Step 1: Download Haskell from following location.

Step 2: Run the installer

Step 3: Add the Haskell bin directory path to your system path.  If you are using Mac (or) any linux system, open terminal and type ‘ghci’ command, if you are using Windows, you should go to All Programs, then GHC; you will see ghci in the list. When you run the command ghci, it opens window like below, starting with version of GHCi followed by Prelude prompt. Prelude is a standard module of GHCi, that provides very useful functions.

$ ghci
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
Prelude> 


‘ghci’ command opens Haskell in interactive mode, you can use this interactive session for learning/experiment purpose.

Prelude> 1+2
3
Prelude> 1-2
-1
Prelude> 1/2
0.5
Prelude> 1*2
2


If you load other libraries, then Prelude prompt changes to new library.

Prelude> import Data.List
Prelude Data.List> 


GHC (Glasgow Haskell Compiler) has following three core components.
Component
Description
Compiler generates native code.
It is an interactive interpreter and debugger.
It is a program used to Haskell programs as scripts.

Note
Prelude is the core library loaded by default in every Haskell program.


Previous                                                 Next                                                 Home

No comments:

Post a Comment