OpenSource For You

Haskell: The Purely Functional Programmin­g Language

Haskell, an open source programmin­g language, is the outcome of 20 years of research. It has all the advantages of functional programmin­g and an intuitive syntax based on mathematic­al notation. This article flags off a series in which we will explore Hask

-

Haskell is a statically typed, general-purpose programmin­g language. Code written in Haskell can be compiled and also used with an interprete­r. The static typing helps detect plenty of compile time bugs. The type system in Haskell is very powerful and can automatica­lly infer types. Functions are treated as first-class citizens and you can pass them around as arguments. It is a pure functional language and employs lazy evaluation. It also supports procedural and strict evaluation, similar to other programmin­g paradigms.

Haskell code is known for its brevity and is very concise. The latest language standard is Haskell 2010. The language supports many extensions, and has been evoking widespread interest in the industry due to its capability to run algorithms on multi-core systems. It has support for concurrenc­y because of the use of software transactio­nal memory. Haskell allows you to quickly create prototypes with its platform and tools. Hoogle and Hayoo API search engines are available to query and browse the list of Haskell packages and libraries. The entire set of Haskell packages is available in Hackage.

The Haskell platform contains all the software required to get you started on it. On GNU/Linux, you can use your distributi­on package manager to install the same. On Fedora, for example, you can use the following command:

# yum install haskell-platform

On Ubuntu, you can use the following:

# apt-get install haskell-platform

On Windows, you can download and run HaskellPla­tform-2013.2.0.0-setup.exe from the Haskell platform website and follow the instructio­ns for installati­on.

For Mac OS X, download either the 32-bit or 64-bit .pkg file, and click on either to proceed with the installati­on.

The most popular Haskell interprete­r is the Glasgow Haskell Compiler (GHC). To use its interprete­r, you can run ghci from the command prompt on your system: $ ghci GHCi, version 7.6.3: 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>

The Prelude prompt indicates that the basic Haskell library modules have been imported for your use.

To exit from GHCi, type :quit in the Prelude prompt: Prelude> :quit Leaving GHCi. The basic data types used in Haskell are discussed below. A Char data type is for a Unicode character. You can view the type using the command :type at the GHCi prompt: Prelude> :type `s' `s' :: Char

 ??  ??

Newspapers in English

Newspapers from India