lean4-htt/tests/lean/Format.lean
Leonardo de Moura 15335efae2 refactor: move Format to Init package
We are going to use it to define `Repr` class.
2020-12-18 11:21:30 -08:00

15 lines
596 B
Text

#lang lean4
open Lean
open Std
open Std.Format
def eval (w : Nat) (f : Format) : IO Unit := do
IO.println $ f.pretty w
-- hard line breaks should re-evaluate flattening behavior within group
#eval eval 5 $ fill (text "a" ++ line ++ text "b\nlooooooooong" ++ line ++ text "c") ++ line ++ text "d"
-- basic `fill` test
#eval eval 20 $ fill (Format.joinSep ((List.range 13).map fun i => i.repeat (fun s => s ++ "a") "a") line)
-- `fill` items that are too big should get dedicated
#eval eval 8 $ fill (Format.joinSep [text "a", text "b", paren (text "ccccc" ++ line ++ text "d"), text "e"] line)