square = join (*) pow x 0 = 1 pow | even y = square $ pow x (y `div` 2) | otherwise = x * pow x (pred y)