--- /dev/null
+module Formatter where
+import Data.List
+
+padWith :: a -> Int -> [a] -> [a]
+padWith _ 0 l = l
+padWith e n [] = replicate n e
+padWith e (n+1) (h:t) = h:(padWith e n t)
+
+formatTable :: [[String]] -> String
+formatTable cells =
+ let columnWidths = map (\col -> maximum $ map length col)
+ $ transpose cells in
+ intercalate "\n" $
+ map (\row ->
+ let rowCells = zipWith (padWith ' ') columnWidths row in
+ intercalate " " rowCells
+ ) cells