How do I pretty-print a table in Haskell? -


i prettyprint table-like data structure in haskell (a list of columns).

for example...

table [     strcol "strings" ["a", "bc", "c"],     intcol "ints" [1, 30, -2],     dblcol "doubles" [2.0, 4.5, -3.2]] 

should render like...

strings ints doubles     "a"    1     2.0    "bc"   30     4.5     "c"   -2    -3.2 

currently have implemented functionality in text.prettyprint comes recent version of haskell platform. unfortunately <+> operator orients multi-line documents "diagonally" each other.

eg

(text "a" $+$ text "b") <+> (text "c" $+$ text "d") 

renders as

a b c   d 

rather than

a c b d 

as result, transpose cells , merge them horizontally first, vertically, results in columns not being aligned.

in older table pretty-printing question, augustss refers adding more code have columns automatically adapt widest entry.

i'm guessing "sizedtext" maximum length of each column this, except function doesn't appear part of haskell platform text.prettyprint module (i think it's in closely related text.pretty package).

what's simplest non-hacky way of implementing pretty-print functionality? small part of project i'd avoid writing own pretty-printing, , i'd prefer avoid module dependencies if can.

http://hackage.haskell.org/package/boxes

the boxes package

a pretty-printing library laying out text in 2 dimensions, using simple box model....


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -