example of Haskell code which works along the same lines as the outline