GaloisInc / cryptol

Cryptol: The Language of Cryptography
https://galoisinc.github.io/cryptol/master/RefMan.html
BSD 3-Clause "New" or "Revised" License
1.14k stars 126 forks source link

Improve pretty printing of values #147

Open weaversa opened 9 years ago

weaversa commented 9 years ago

Another older request ---

  1. It'd be useful to display lists of records (or tuples) in tabular form

    [ { x = 1, y = 2 }
    , { x = 3, y = 4 }
    ]
  2. It'd be nice to have a mode that displays lists of lists as matrices

    [ [1,2,3]
    , [4,5,6]
    , [7,8,9]
    ]
  3. It'd be nice to have a mode where lists of booleans are displayed so, and not turned into words:

    [ True, False, False, True ]
LeventErkok commented 9 years ago

Cryptol-1 used to have a function called format which allowed users to program any sort of pretty printing, including vertical/horizontal layouts, padding, spaces/0-filling, left/right flushing etc. in a type-safe manner. It wasn't the easiest function to use, but I do believe it had provisions for coding all of the use-cases you have above in rather a concise way. Maybe time to bring that back from the dead!

dylanmc commented 8 years ago

Marked as low-hanging to request a 20% effort that gives us 80% of the Yak shave.

brianhuffman commented 5 years ago

One easy-to-implement feature would be to add a :set option for pretty-printing width; tweaking it might help to put line breaks in more desirable places.

Another thing we could do is write a library of pretty-printing combinators in Cryptol that could do fancy formatting. (I guess this would be similar to what Cryptol-1's format was?)

brianhuffman commented 4 years ago

A 20% effort might be just to tweak the line-breaking and indentation heuristics to make things line up vertically more often.