solved prob2.hs