- Functions as first-class values.
- Algebraic and abstract data types.
- Polymorphism and classes.
- Testing functional programs.
- Lazy evaluations and infinite objects.
- Monads.

- Write small to medium-sized functional programs for a variety of applications.
- Exploit a variety of programming techniques typical in functional
programming, such as:
- Use of recursion,
- Modelling with recursive datatypes,
- Abstraction and reuse with the help of higher order functions and monads.

- Appreciate the strengths and possible weaknesses of the functional programming paradigm.

- This is a key aspect of functional programming.
- Higher order functions
- Powerful way to build modular and reusable code.
- Especially when combined with polymorphism.

- Powerful way to build modular and reusable code.
- Using functions to represent data

**data****Set**`a``empty`**::****Set**`a``singleton`**::**`a`**->****Set**`a``insert`**::**`a`**->****Set**`a`**->****Set**`a``union`,`intersection`,`difference`**::****Set**`a`**->****Set**`a`**->****Set**`a``complement`**::****Set**`a`**->****Set**`a``member`**::**`a`**->****Set**`a`**->****Bool**`toList`**::****Set**`a`**->**[`a`]- Probably need some constraints, or
**Eq**`a`, depending on implementation.**Ord**`a`

- Lists
**data****Set**`a`**=****Set**[`a`]

- Binary search trees
**data****Set**`a`**=****Empty****|****Node**`a`(**Set**`a`) (**Set**`a`)

- Functions
**data****Set**`a`**=****Set**(`a`**->****Bool**)

- Which is easier?

**data****Set**`a`**=****Set**[`a`] -- Invariant: no duplicates`empty`**=****Set**[]`singleton``x`**=****Set**[`x`]`insert``x`(**Set**`xs`)**|**`x```elem```xs`**=****Set**`xs`**|**`otherwise`**=****Set**(`x`**:**`xs`)`member``x`(**Set**`xs`)**=**`x```elem```xs``union`(**Set**`xs`) (**Set**`ys`)**=****Set**(`xs``++`[`y`**|**`y`**<-**`ys`,`y```notElem```xs`])`intersection`(**Set**`xs`) (**Set**`ys`)**=****Set**[`x`**|**`x`**<-**`xs`,`x```elem```ys`]`difference`(**Set**`xs`) (**Set**`ys`)**=****Set**[`x`**|**`x`**<-**`xs`,`x```notElem```ys`]- Fairly easy.
Only finite sets. Only types in the class. No
**Eq**.`complement` - Variant: keep the lists ordered for efficiency…

**data****Set**`a`**=****Empty****|****Node**`a`(**Set**`a`) (**Set**`a`) -- Invariant: smaller elements to the left, -- bigger to the right`empty`**=****Empty**`singleton``x`**=****Node**`x`**Empty****Empty**`insert``x`**Empty****=**`singleton``x``insert``x`(**Node**`y``l``r`)**|**`x``==``y`**=****Node**`y``l``r`**|**`x``<``y`**=****Node**`y`(`insert``x``l`)`r`**|**`x``>``y`**=****Node**`y``l`(`insert``x``y`)`member``x`**Empty****=****False**`member``x`(**Node**`y``l``r`)**=**`x``==``y``||``member``x`(**if**`x``<``y`**then**`l`**else**`r`)- More complicated.
Only finite sets. Only types in the class. No
**Ord**.`complement` - Even more complicated if we want to keep the trees balanced. (Data.Set)

**data****Set**`a`**=****Set**(`a`**->****Bool**)`empty`**=****Set**(`const`**False**)`singleton``x`**=****Set**(`==``x`)`insert``x``s`**=**`union`(`singleton``x`)`s``member``x`(**Set**`f`)**=**`f``x``union`(**Set**`f`) (**Set**`g`)**=****Set**(**\**`x`**->**`f``x``||``g``x`)`intersection`(**Set**`f`) (**Set**`g`)**=****Set**(**\**`x`**->**`f``x``&&``g``x`)`complement`(**Set**`f`)**=****Set**(`not``.``f`)`difference``s1``s2`**=**`intersection``s1`(`complement``s2`)- It's the easiest of the three! All operations are one-liners!
- Allows infinite sets and , but no
`complement`, unlike the others.`toList`

**type****Region****=****Point****->****Bool****type****Point****=**(**Double**,**Double**)- This makes all operations on regions easy to define
- Basic shapes: circles, rectangles, etc
- Geometric transformations, e.g. moving, scaling & rotating regions
- Unions, intersections, complements
- Membership tests

- GHC is implemented in Haskell.
- Hackage: lots of free Haskell libraries and applications.
- Investment banking: financial modelling, quantitative analysis.
- Facebook: HaXL, spam filtering.
- Keera Studios: game development, Android.
- More: Haskell in Industry
- Haskell Communities and Activities Report, November 2017 issue

- 14,000 new Haskell projects on Github!
It’s really never been an easier and more exciting time to be programming professionally in the world’s most advanced (yet usable) statically typed language.

- These slides: formatting and syntax high-lighting.
- WebFudgets.
- Programatica: Haskell compiler front-end (2001-2006)
- House: a prototype operating system in Haskell (2004-2006)
- Hardware emulation (6502 8-bit processor, used in C-64)
- An e-commerce system in Haskell (2006-2009)
- A web browser in Haskell (mid 1990s)
- Alfa: GUI for the proof assisant Agda (mid 1990s)
- Fudgets: GUI library in Haskell (early 1990s)

- Keynote: Why Functional Programming Matters - John Hughes, Mary Sheeran (Code Mesh, London 2015)

- Good luck with your projects!
- See you next week!