Pages

Monday, 4 February 2013

Installing Haskell on Linux

Installing Haskell in Linux is very easy if you have an Internet connection.

Just open terminal and go to root prompt and type :

~#  apt-get update && apt-get install ghc6 ghc6-doc ghc6-proc

It will install the basic packages of Haskell.

To check whether the packages are installed or not, just type on terminal :

~$ ghci

if packages are install properly, it will show you the following thing :

GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude>

else it will give you an error..



So, since we have installed a Haskell, now its time to install it completely..

i.e.

"Installing all the packages of Haskell, so that we can see the real  power of Haskell"       

 Haskell is very powerful programming language. It can do everything that c, c++ and Java can, in very efficient manner.

For more information about Haskell :

Haskell site : www.haskell.org

Haskell wiki info : http://en.wikipedia.org/wiki/Haskell_%28programming_language%29

         But to see the actual power of Haskell, we should have everything related to Haskell, installed on our machine. But when we install Haskell normally, not all packages get installed. In Synaptic Package Manager, we can see only the basic packages for Haskell, in "Haskell Programming Language" section. (Just go to SPM to see Haskell packages, they will be less in number).

        So to include all the packages into the Synaptic Package Manager, you have to fire the following command on terminal on root prompt :

 $ apt-get update && apt-get install haskell-platform

       If you have an Internet connection, this command will directly fetch all the packages of Haskell from the Internet.  Now again check "Haskell Programming Language" section in Synaptic Package Manager.

      You will see the huge list of unmarked packages. You just have to mark them and click on "APPLY", and the package manager will do the rest.

      After Complete installation of all Haskell packages, you can check the increase in the Haskell modules by using following commands :
-----------------------------------------------------------------------------------------------------------------------------------
 $ ghci

GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

Prelude> :module  (press TAB)
Display all 4054 possibilities? (y or n)         (press y)
AI.SimpleEA
AI.SimpleEA.Utils
Agda.Auto.Auto
Agda.Auto.CaseSplit
Agda.Auto.Convert
Agda.Auto.NarrowingSearch
Agda.Auto.SearchControl
Agda.Auto.Syntax
Agda.Auto.Typecheck
Agda.Compiler.Epic.AuxAST
Agda.Compiler.Epic.CaseOpts
Agda.Compiler.Epic.CompileState
Agda.Compiler.Epic.Compiler
Agda.Compiler.Epic.Epic
Agda.Compiler.Epic.Erasure
Agda.Compiler.Epic.ForceConstrs
Agda.Compiler.Epic.Forcing
Agda.Compiler.Epic.FromAgda
Agda.Compiler.Epic.Injection
Agda.Compiler.Epic.Interface
Agda.Compiler.Epic.NatDetection
Agda.Compiler.Epic.Primitive
Agda.Compiler.Epic.Smashing
----More----
-----------------------------------------------------------------------------------------------------------------------------------

Now with all the Haskell packages installed on your machine, You can do so many beautiful things with Haskell..

To start up the things, here is a simple "graphics code in Haskell"..

file name : graphics.hs

import Graphics.UI.Gtk

main :: IO ()
main = do
  initGUI
  window <- windowNew
  label <- labelNew $ Just "Hello, world from gtk2hs!"
  set window [ containerBorderWidth := 20,
               containerChild := label ]
  onDestroy window mainQuit
  widgetShowAll window
  mainGUI


to run this program :  type

>  ghc --make graphics.hs -o graphics
>  ./graphics

It will execute this graphics program.

No comments:

Post a Comment