@@ -61,7 +61,7 @@ cellLocations tab@(header, _) = (maxWidths, maxHeights)
6161 maxWidths = foldl mergeMax (baseSize (length header)) (map fst cellSizeMatrix)
6262 baseSize num = take num (repeat 0)
6363 rowHeights = map snd cellSizeMatrix
64− maxHeights = map (L.maximumBy compare) rowHeights
64+ maxHeights = map (\l -> if length l == 0 then 0 else L.maximumBy compare l) rowHeights
6565 mergeMax a b = map (\(c,d) -> max c d) (zip a b)
6666
6767--the normal "lines" function returns an empty list for an empty string which is not what we want
@@ -72,7 +72,11 @@ breakLines x = T.lines x
7272cellSizes :: Table -> [([Int], [Int])]
7373cellSizes (header, body) = map (\row -> (map maxRowWidth row, map (length . breakLines) row)) allRows
7474 where
75− maxRowWidth row = L.maximumBy compare (map T.length (breakLines row))
75+ maxRowWidth row = if length (lengths row) == 0 then
76+ 0
77+ else
78+ L.maximumBy compare (lengths row)
79+ lengths row = map T.length (breakLines row)
7680 allRows = [header] ++ body
7781
7882relationAsTable :: Relation -> Table
@@ -137,13 +141,4 @@ repeatString :: Int -> StringType -> StringType
137141repeatString c s = T.concat (take c (repeat s))
138142
139143showRelation :: Relation -> StringType
140−showRelation rel
141− | rel == relationTrue = "true"
142− | rel == relationFalse = "false"
143− | otherwise = renderTable (relationAsTable rel)
144−
145−
146−{-
147−groupedExample :: Relation
148−groupedExample = case group (S.fromList ["CITY"]) "CITYREL" s of {Right rel -> rel}
149−-}
144+showRelation rel = renderTable (relationAsTable rel)