Design and Analysis of Purely Functional Programs