Error-writing utilities #
This module presents some convenience utilities for writing error and status messages in the Lean compiler.
New operations on lists and strings are intended to operate through the dot-notation-respects-notation
mechanism (https://juliahimmel.de/blog/an-underappreciated-lean-feature).
To use n.toOrdinal in a module, first open Lean.Internal.ErrorUtils.
Translate numbers (1, 2, 3, 212, 322 ...) to ordinals with appropriate English-language names for small ordinals (0 through 10 become "zeroth" through "tenth") and postfixes for other numbers (212 becomes "212th" and 1292 becomes "1292nd").
Equations
- One or more equations did not get rendered due to their size.
- Lean.Internal.ErrorUtils.Nat.toOrdinal 0 = "zeroth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 1 = "first"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 2 = "second"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 3 = "third"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 4 = "fourth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 5 = "fifth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 6 = "sixth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 7 = "seventh"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 8 = "eighth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 9 = "ninth"
- Lean.Internal.ErrorUtils.Nat.toOrdinal 10 = "tenth"
Instances For
- emp : α
- and : α
- comma : α
- commaAnd : α
Instances
@[instance_reducible]
Equations
- Lean.Internal.ErrorUtils.instHasOxfordStringsString = { emp := "", and := " and ", comma := ", ", commaAnd := ", and " }
@[instance_reducible]
Equations
- One or more equations did not get rendered due to their size.
def Lean.Internal.ErrorUtils.List.toOxford {α : Type u_1} [Append α] [HasOxfordStrings α] :
List α → α
Make an oxford-comma-separated list of strings.
["eats"].toOxford == "eats"["eats", "shoots"].toOxford == "eats and shoots"["eats", "shoots", "leaves"] == "eats, shoots, and leaves"
Equations
- Lean.Internal.ErrorUtils.List.toOxford [] = Lean.Internal.ErrorUtils.HasOxfordStrings.emp
- Lean.Internal.ErrorUtils.List.toOxford [a] = a
- Lean.Internal.ErrorUtils.List.toOxford [a, b] = a ++ Lean.Internal.ErrorUtils.HasOxfordStrings.and ++ b
- Lean.Internal.ErrorUtils.List.toOxford [a, b, c] = a ++ Lean.Internal.ErrorUtils.HasOxfordStrings.comma ++ b ++ Lean.Internal.ErrorUtils.HasOxfordStrings.commaAnd ++ c
- Lean.Internal.ErrorUtils.List.toOxford (a :: as) = a ++ Lean.Internal.ErrorUtils.HasOxfordStrings.comma ++ Lean.Internal.ErrorUtils.List.toOxford as
Instances For
- singular : α
- plural : α → α
Instances
@[instance_reducible]
@[instance_reducible]
Equations
- Lean.Internal.ErrorUtils.instHasPluralDefaultsMessageData = { singular := Lean.MessageData.nil, plural := fun (x : Lean.MessageData) => Lean.toMessageData x ++ Lean.toMessageData "s" }
def Lean.Internal.ErrorUtils.Nat.plural {α : Sort u_1} [HasPluralDefaults α] (count : Nat) (singular : α := HasPluralDefaults.singular) (plural : α := HasPluralDefaults.plural singular) :
α
Give alternative forms of a string if the count is 1 or not.
(1).plural == ""(2).plural == "s"(1).plural "wug" == "wug"(2).plural "wug" == "wugs"(1).plural "it" "they" == "it"(2).plural "it" "they" == "they"