[Convert from ML to Haskell David Fox **20080707133944]