Safe Haskell | None |
---|---|
Language | Haskell98 |
Documentation
tab :: Presentable a => a -> IO () Source #
Print a nested value to the console in tabular form.
The first two layers of nesting are displayed as rows and columns. Numeric data is right-justified, while the rest is left-justified.
> tab [[10, 20, 302], [40, 50], [60, 7001, 80, 90 :: Int]] 10 20 302 40 50 60 7001 80 90
Deeper layers of nesting are preserved in the output:
> tab [[[10], [20, 21]], [[30, 31], [40, 41, 41], [50 :: Int]]] [10] [20,21] [30,31] [40,41,41] [50]
By default, strings are printed as lists of characters:
> tab [[("red", 10), ("green", 20), ("blue", 30)], [("grey", 40), ("white", 50 :: Int)]] (['r','e','d'],10) (['g','r','e','e','n'],20) (['b','l','u','e'],30) (['g','r','e','y'],40) (['w','h','i','t','e'],50)
If you want double-quotes then wrap the strings with a Str
constructor:
> tab [[(Str "red", 10), (Str "green", 20), (Str "blue", 30)], [(Str "grey", 40), (Str "white", 50 :: Int)]] ("red",10) ("green",20) ("blue",30) ("grey",40) ("white",50)
If you don't want any quotes then wrap them with a Tok
constructor:
> tab [[(Tok "red", 10), (Tok "green", 20), (Tok "blue", 30)], [(Tok "grey", 40), (Tok "white", 50 :: Int)]] (red,10) (green,20) (blue,30) (grey,40) (white,50)
tabulate :: Presentable a => a -> Text Source #
Display a nested value in tabular form.
Wrapper to indicate a list of characters should be printed as a string, including double quotes.