Haskell implementation of discrete mathematics