Haskell code, test to be submitted for wiser eyes than mine