module Presentation(showTable) where import Data.List( transpose ) showTable = unlines . insertSeparator . tableLines . autoPadTable insertSeparator (title:rest) = title : separator : rest where separator = replicate (length title) '-' padTable colSizes rows = map padRow rows where pad s l = s ++ replicate (l - length s) ' ' padRow row = zipWith pad row colSizes autoPadTable rows = padTable colSizes rows where cols = transpose rows colSizes = map (maximum . map length) cols tableLines = map (concat . map (' ':))