P23: Added Haskell solution, tweaked Java solution.