adding haskell recursive implementation