Pretty Print
Pretty printer for HorseIR programs
Pretty printer.
Principles¶
We propose a couple of pretty printing modes as follows.
- Print all elements (real numbers, complex numbers and symbols)
- Print abbreviations for advanced types (nested lists, dictionary, enumeration, tables and keyed tables)
- Print customized sizes (e.g. 20 rows and 5 columns max)
- Print within current window (Optional)
Basic types¶
Bool¶
(0,1):bool
Short¶
(10,20):i16
Int¶
(1234567,2):i32
Long¶
(123456789012345,123):i64
(123456789012345,123)
Float¶
(12.3,2.5):f32
Double¶
(12.3,2.5)
(12.3,2.5):f64
Char¶
'abcd'
'abcd':char
Complex numbers¶
(1+2i,2,3i)
(1+2i,2,3i):complex
Symbols¶
(`apple,`"my name"):sym
(`apple,`"my name")
Compound types¶
List¶
Input literal:
[(1,2,3):i32, (2,0.5):f32]
Output:
[(1,2,3):i32, (2,0.5):f32]
Dictionary¶
Input literal:
{`key1 -> (1,2,3):i32, `key2 -> (2,0.5):f32}
Output:
{
`key1 -> (1,2,3):i32,
`key2 -> (2,0.5):f32
}
Enumeration¶
Input literal:
<`u, (`a,`b,`c):sym>
Output:
<`u, (`a,`b,`c)>
Table¶
Input literal:
{`col1 -> (`a,`b,`c), `col2 -> (1,2,3):i32}
Output:
col1 col2
---------
a 1
b 2
c 3
Keyed table¶
Input literal:
{[`col1 -> (`a,`b,`c)], `col2 -> (1,2,3):i32}
Output:
col1 | col2
-----------
a | 1
b | 2
c | 3