hmt-base-0.20: Haskell Music Theory Base
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Array.Text

Description

Regular array data as plain text tables.

Synopsis

Documentation

type Text_Table = [[String]] Source #

Tabular text.

table_split :: [Int] -> Text_Table -> [Text_Table] Source #

Split table at indicated places.

let tbl = [["1","2","3","4"],["A","B","E","F"],["C","D","G","H"]]
table_split [2,2] tbl

table_concat :: [Text_Table] -> Text_Table Source #

Join tables left to right.

table_concat [[["1","2"],["A","B"],["C","D"]],[["3","4"],["E","F"],["G","H"]]]

table_number_rows :: Int -> Text_Table -> Text_Table Source #

Add a row number column at the front of the table.

table_number_rows 0 tbl

type Text_Table_Opt = (Bool, Bool, Bool, String, Bool) Source #

(HEADER,PAD-LEFT,EQ-WIDTH,COL-SEP,TBL-DELIM).

Options are: has header pad text with space to left instead of right, make all columns equal width, column separator string, print table delimiters

table_opt_plain :: Text_Table_Opt Source #

Options for plain layout.

table_opt_simple :: Text_Table_Opt Source #

Options for simple layout.

table_opt_pipe :: Text_Table_Opt Source #

Options for pipe layout.

table_pp :: Text_Table_Opt -> Text_Table -> [String] Source #

Pretty-print table. Table is in row order.

let tbl = [["1","2","3","4"],["a","bc","def"],["ghij","klm","no","p"]]
putStrLn$unlines$"": table_pp (True,True,True," ",True) tbl
putStrLn$unlines$"": table_pp (False,False,True," ",False) tbl

table_pp_show :: Show t => Text_Table_Opt -> Table t -> [String] Source #

Variant relying on Show instances.

table_pp_show table_opt_simple [[1..4],[5..8],[9..12]]

table_pp_column_order :: Text_Table_Opt -> Text_Table -> [String] Source #

Variant in column order (ie. transpose).

table_pp_column_order table_opt_simple [["a","bc","def"],["ghij","klm","no"]]

table_matrix :: ([String], [String]) -> Text_Table -> Text_Table Source #

Matrix form, ie. header in both first row and first column, in each case displaced by one location which is empty.

let h = (map return "abc",map return "efgh")
let t = table_matrix h (map (map show) [[1,2,3,4],[2,3,4,1],[3,4,1,2]])
>>> putStrLn $ unlines $ table_pp table_opt_simple t
- - - - -
  e f g h
a 1 2 3 4
b 2 3 4 1
c 3 4 1 2
- - - - -

table_matrix_opt :: (a -> String) -> (String -> String) -> ([a], [a]) -> Table a -> Text_Table Source #

Variant that takes a show function and a header decoration function.

table_matrix_opt show id ([1,2,3],[4,5,6]) [[7,8,9],[10,11,12],[13,14,15]]