Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/init/meta/format.lean
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ meta instance : has_append format :=
⟨format.compose⟩

meta instance : has_to_string format :=
⟨λ f, f.to_string options.mk
⟨λ f, f.to_string⟩

/-- Use this instead of `has_to_string` to enable prettier formatting.
See docstring for `format` for more on the differences between `format` and `string`.
Note that `format` is `meta` while `string` is not. -/
meta class has_to_format (α : Type u) :=
(to_format : α → format)

@[priority 10] meta instance has_to_format_has_to_string {α} [has_to_format α]
: has_to_string α :=
⟨has_to_string.to_string ∘ has_to_format.to_format⟩

meta instance : has_to_format format :=
⟨id⟩

Expand Down