Zulip Chat Archive

Stream: lean4

Topic: Pretty printing custom list literal


ohhaimark (Jul 15 2022 at 01:00):

What is actually used to pretty print List in lean? I have a list literal notation for Vec, implemented Repr, ToFormat and looked at the Delaborator for reference, but I can't figure it out.

Mac (Jul 15 2022 at 02:23):

These @[appUnexpander] definitions from Init.NotationExtra:

@[appUnexpander List.nil] def unexpandListNil : Lean.PrettyPrinter.Unexpander
  | `($(_)) => `([])
  | _       => throw ()

@[appUnexpander List.cons] def unexpandListCons : Lean.PrettyPrinter.Unexpander
  | `($(_) $x [])      => `([$x])
  | `($(_) $x [$xs,*]) => `([$x, $xs,*])
  | _                  => throw ()

See the source code here.


Last updated: Dec 20 2023 at 11:08 UTC