on master help sign in
show relational true and false as boxes instead of text because they can appear due to grouping
98ee637AgentM
ProjectM36/Relation/Show/Term.hs+7−12
@@ -61,7 +61,7 @@ cellLocations tab@(header, _) = (maxWidths, maxHeights)
61 maxWidths = foldl mergeMax (baseSize (length header)) (map fst cellSizeMatrix)
61 maxWidths = foldl mergeMax (baseSize (length header)) (map fst cellSizeMatrix)
62 baseSize num = take num (repeat 0)
62 baseSize num = take num (repeat 0)
63 rowHeights = map snd cellSizeMatrix
63 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
65 mergeMax a b = map (\(c,d) -> max c d) (zip a b)
65 mergeMax a b = map (\(c,d) -> max c d) (zip a b)
66
66
67--the normal "lines" function returns an empty list for an empty string which is not what we want
67--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
72cellSizes :: Table -> [([Int], [Int])]
72cellSizes :: Table -> [([Int], [Int])]
73cellSizes (header, body) = map (\row -> (map maxRowWidth row, map (length . breakLines) row)) allRows
73cellSizes (header, body) = map (\row -> (map maxRowWidth row, map (length . breakLines) row)) allRows
74 where
74 where
75+ maxRowWidth row = if length (lengths row) == 0 then
76+ 0
77+ else
78+ L.maximumBy compare (lengths row)
75− maxRowWidth row = L.maximumBy compare (map T.length (breakLines row))
79+ lengths row = map T.length (breakLines row)
76 allRows = [header] ++ body
80 allRows = [header] ++ body
77
81
78relationAsTable :: Relation -> Table
82relationAsTable :: Relation -> Table
@@ -137,13 +141,4 @@ repeatString :: Int -> StringType -> StringType
137repeatString c s = T.concat (take c (repeat s))
141repeatString c s = T.concat (take c (repeat s))
138
142
139showRelation :: Relation -> StringType
143showRelation :: Relation -> StringType
140−showRelation rel
141− | rel == relationTrue = "true"
142− | rel == relationFalse = "false"
143− | otherwise = renderTable (relationAsTable rel)
144+showRelation rel = renderTable (relationAsTable rel)
144−
145−
146−{-
147−groupedExample :: Relation
148−groupedExample = case group (S.fromList ["CITY"]) "CITYREL" s of {Right rel -> rel}
149−-}