[Haskell-cafe] how to optmize this code?