paip code translated to haskell