[haskell] refactor to remove extra function
[haskell] refactor to a datatype