Solution to 001 in Haskell