--
module SimpleDesignRecipeExample where

import Test.HUnit(Test(TestCase,TestList),assertEqual,runTestTT)

-- 1) understand the problem
--  length counts the number of items in a list
-- the type of elements in the list is in materil and doesn't matter


-- write a contract
len:: forall a . [ a ] -> Int


-- 3) make some examples

ex1 = assertEqual "empty" (len [])  0
ex2 = assertEqual "all the same" (len [1,1,1,1]) 4
ex3 = assertEqual "two" (len [1,2]) 2

-- 4)
len [] = 0
len (x:xs) = 1 + len xs

-- 5 perform some tests

lenTest = TestList[TestCase ex1, TestCase ex2, TestCase ex3]
tests = runTestTT lenTest

--