[Haskell-beginners] best way to code this