Haskell's almost painless guide to getting Started

Source: Internet
Author: User

Take advantage of the opportunity to reinstall your Linux virtual machine by documenting the process of installing Haskell, and helping readers who are still hesitant to wander outside the Haskell Gate.

Basic concepts:

Haskell:

is a universal functional language, almost able to do whatever kind of development, including command line, GUI, database, Web. Source code can cross platform: Linux,mac, Windows, FreeBSD, etc.

Features of Haskell:

The functional style is the main type and the command style is supplemented by a strict and easy-to-use system. Type checking helps the ape to avoid very many errors during the development process and assists in the structure of the Organization's program.

Haskell's Development tools:

There are mainly GHC, hugs two species, there is no use of NHC did not say. We're going to install the GHC, and Haskell Platform on the GHC basis.

GHC

Full name: Glasgow Haskell Compiler, including an efficient Haskell compiler GHC, and an interpreter ghci for a similar Python interactive environment. GHC is able to compile and build efficient, operational programs.

Haskell Platform

Haskell Platform is a packaged Haskell development environment, including GHC and very many third-party development libraries, as well as cabal package managers.

What is Cabal again?

Simply said is Ubuntu Apt-get, Perl cpan, Python easy_install, Ruby Gem. That's a definite thing to say.

To install a third-party library, just need: Cabal install Lib-name will be able to. It was almost so simple.

How do I install a third-party repository for Haskell?

There is something hackagedb similar to Perl's CPAN, this list includes a third-party library that Haskell can use. Install in the same way: Cabal install libname will be able to. Most libraries are very easy to install, but some third-party libraries rely on certain system-specific libraries, so they are not always installed smoothly.

===================

installation process

(This article is based on Ubuntu 9.10 and is also applicable for other Apt-get-based Linux.) )

1. Installing dependent libraries

sudoapt-get installlibedit2 libedit-dev freeglut3-dev libglu1-mesa-dev libgmp3-dev

2. Download GHC

On the GHC download page, select the appropriate version number to download (x86, x86_64), than for example the x86 version number Linux:

wget http://haskell.org/ghc/dist/6.12.1/ghc-6.12.1-i386-unknown-linux-n.tar.bz2

3. Installing GHC

$ tar jxvf ghc-6.12.1-i386-unknown-linux-n.tar.bz2

$ CD ghc-6.12.1

$./configure

$ sudo make install

After installation, test:


4. Install Haskell Platform

Download: wget http://hackage.haskell.org/platform/2010.1.0.0/haskell-platform-2010.1.0.0.tar.gz

Unzip,./configure, make, make install

Make can be a long process, compiling a whole bunch of third-party libraries.

5. Configuration of the Cabal

After the Haskell Platform is installed, the user is prompted for cabal update, which is to update the folder list for the following libraries:

$ cabal Update

To install a library, first locate the required library on Hackagedb, and then execute the Cabal install to:

=====================

Hello World

After all that time, I finally got to my favorite Hello world stage.

GHCi This interactive environment

The Haskell program is able to interpret both the run and the compile run, which is very handy for debugging during the development process.

> Print "Hello World"

"Hello World"

It looks very easy, nothing surprising. Here are some interesting things to try:

Compiling the program

The following to write a complete program, and compiled into a executable file, first write Hello.hs file, content such as the following, compiled with GHC.


Haskell's editing environment

A grand recommendation Emacs, Emacs Haskell-mode in the code, help with indentation, syntax highlighting, with Unicode display, can get a very beautiful effect.

Also open a specific explanation of the Emacs environment.


Haskell's almost painless guide to getting Started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.