Introduction to functional programming and Haskell

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Mainstream languages are imperative or object-oriented; functional programs are more like mathematical expressions, i.e., without side-effects

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods In traditional languages, even the simplest aspects of algebraic and equational reasoning can fail ```f(x) + f(x) == 2 * f(x) g(y) == g(y)```

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods A high-level perspective on programming Powerful abstraction features (higher-order functions, polymorphic types, etc.) allow for very concise expression of programs and a high "signal-to-noise" ratio ```quicksort [] = [] quicksort (x:xs) = quicksort small ++ [x] ++ quicksort large where small = [y | y<-xs, y< x] large = [y | y<-xs, y>=x]```

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods A high-level perspective on programming Haskell and other functional programming languages Most functional languages (LISP, APL, Scheme, ML) make concessions to side-effects; Haskell is a study in pure functional style (plus, it uses a familiar algebraic syntax)

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods A high-level perspective on programming Haskell and other functional programming languages Regional relevance in the Northwest the OGI Pacsoft group is a world leader in Haskell and FP Intel uses Haskell and other FPs for hardware modeling and development Galois Connections: a profitable private company with industrial and government contracts Microsoft has bought into Haskell, both in Cambridge and Redmond

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods A high-level perspective on programming Haskell and other functional programming languages Regional relevance in the Northwest Overview of the tutorial basic syntax and features of Haskell (by example) short applications (text processing, number bases, DFA simulation, etc.) medium-sized example: generic sorting and simple database medium-sized example: parsing and evaluating a simple expression language medium-sized example: simple vector graphics package overview of larger applications and libraries (music, graphics, animation, GUIs, web, etc.)

```

```

 3rd CCSC Northwest Conference • Fall 2001

Introduction to functional programming and Haskell
 Functional languages: an alternative paradigm Lack of side-effects facilitates logical reasoning and formal methods A high-level perspective on programming Haskell and other functional programming languages Regional relevance in the Northwest Overview of the tutorial Haskell tools and resources (see also the physical hand-out)

```

```