Generic haskell code