Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Beginning Haskell

An introduction to functional programming

David Mertz, Ph.D. (mertz@gnosis.cx), Developer, Gnosis Software
David Mertz
David Mertz has been writing the developerWorks columns Charming Python and XML Matters since 2000. Check out his book Text Processing in Python . For more on David, see his personal Web page. You can contact David at mertz@gnosis.cx.

Summary:  This tutorial is for programmers of imperative languages wanting to learn about functional programming in the language Haskell. If you have programmed in languages such as C, Pascal, Fortran, C++, Java™, Cobol, Ada, Perl, TCL, REXX, JavaScript, Visual Basic, or many others, you have been using an imperative paradigm. This tutorial provides a gentle introduction to the paradigm of functional programming, with specific illustrations in the Haskell 98 language.

Date:  27 Sep 2001
Level:  Introductory PDF:  A4 and Letter (67 KB | 17 pages)Get Adobe® Reader®

Activity:  37859 views
Comments:  

Before you start

About this tutorial

This tutorial targets programmers of imperative languages wanting to learn about functional programming in the language Haskell.

In an introductory tutorial, many of Haskell's most powerful and complex features cannot be covered. In particular, the whole area of type classes and algebraic types (including abstract data types) is a bit much for a first introduction. For readers whose interest is piqued, I will mention that Haskell allows you to create your own data types, and to inherit properties of those data types in type instances. The Haskell type system contains the fundamental features of object-oriented programming (inheritance, polymorphism, encapsulation); but in a way that is almost impossible to grasp within a C++/Java/Smalltalk/Eiffel style of thinking.

The other significant element omitted in this tutorial is a discussion of monads, and therefore of I/O. It seems strange to write a tutorial that does not even start with a "Hello World!" program, but thinking in a functional style requires a number of shifts. While that "Hello World!" is quite simple, it also involves the mini "pseudo-imperative" world of monads. It would be easy for a beginner to be lulled by the pseudo-imperative style of I/O, and miss what is really going on. Swimming is best learned by getting in the water.


Prerequisites

This tutorial has no prerequisites. Programmers who have not used functional programming, or Haskell 98 in particular, will benefit most from this tutorial.

1 of 7 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=132894
TutorialTitle=Beginning Haskell
publish-date=09272001
author1-email=mertz@gnosis.cx
author1-email-cc=