Advanced Programming Concepts using Haskell

An introduction

Tony Morris

Revision History
Revision $LastChangedRevision$ $LastChangedDate$
Initial authoring

Abstract

This article is intended as a presentation for an introduction to advanced programming concepts using Haskell. This presentation introduces automated specification-based testing.

This presentation is hands-on and requires each member of the audience have access to a computer running the Glasgow Haskell Compiler (GHC) which is available from http://haskell.org/ghc.


Table of Contents

Get Started
Are we good to go?
Haskell
Pure? Lazy?
Automated testing
A note on purity
Purity
Improved code
Let's Go!
Source file
Load the file
Our First Property
Multiplicative Right Identity
Let's do it again
And a bit more
Eschew Repetition!
DeMorgan's Laws
Let's Get It Wrong
Subtraction Commutes
Take n
take
Take One
Take Two
Implication
==>
See a problem?
Fixed!
Test Driven Development for clever people
TDD
Now this one
And finally
Correctness guarantees
Non-total
Now try this one
Only one person lives here
Mocking
Mocking for clever programmers
Let's try it
Really?
Custom Data Type
Quantifying over our own type
A function accepting Person
Write a property
Arbitrary Person
Using an existing Arbitrary
In fact
In double fact
What Pattern?
Name?
Java?
But that's for another day :)
A. Testing.hs

Sometimes asking #haskell for help can be like taking a drink from a fire hose -- Brent Yorgey