Documentation

Init.Data.Repr

class Repr (α : Type u) :

The standard way of turning values of some type into Format.

When rendered this Format should be as close as possible to something that can be parsed as the input value.

  • reprPrec : αNatStd.Format

    Turn a value of type α into a Format at a given precedence. The precedence value can be used to avoid parentheses if they are not necessary.

Instances
    @[reducible, inline]
    abbrev repr {α : Type u_1} [Repr α] (a : α) :

    Turns a into a Format using its Repr instance. The precedence level is initially set to 0.

    Instances For
      @[reducible, inline]
      abbrev reprStr {α : Type u_1} [Repr α] (a : α) :

      Turns a into a String using its Repr instance, rendering the Format at the default width of 120 columns.

      The precedence level is initially set to 0.

      Instances For
        @[reducible, inline]
        abbrev reprArg {α : Type u_1} [Repr α] (a : α) :

        Turns a into a Format using its Repr instance, with the precedence level set to that of function application.

        Together with Repr.addAppParen, this can be used to correctly parenthesize function application syntax.

        Instances For
          class ReprAtom (α : Type u) :

          Auxiliary class for marking types that should be considered atomic by Repr methods. We use it at Repr (List α) to decide whether bracketFill should be used or not.

            Instances
              @[implicit_reducible]
              instance instReprId {α : Type u_1} [Repr α] :
              Repr (id α)
              @[implicit_reducible]
              instance instReprId_1 {α : Type u_1} [Repr α] :
              Repr (Id α)
              @[implicit_reducible]
              Instances For
                @[implicit_reducible]

                Adds parentheses to f if the precedence prec from the context is at least that of function application.

                Together with reprArg, this can be used to correctly parenthesize function application syntax.

                Instances For
                  Instances For
                    @[implicit_reducible]
                    instance instReprDecidable {p : Prop} :
                    @[implicit_reducible]
                    @[implicit_reducible]
                    instance instReprULift {α : Type u_1} [Repr α] :
                    Repr (ULift α)
                    @[implicit_reducible]
                    def Option.repr {α : Type u_1} [Repr α] :
                    Option αNatStd.Format

                    Returns a representation of an optional value that should be able to be parsed as an equivalent optional value.

                    This function is typically accessed through the Repr (Option α) instance.

                    Instances For
                      @[implicit_reducible]
                      instance instReprOption {α : Type u_1} [Repr α] :
                      def Sum.repr {α : Type u_1} {β : Type u_2} [Repr α] [Repr β] :
                      α βNatStd.Format
                      Instances For
                        @[implicit_reducible]
                        instance instReprSum {α : Type u_1} {β : Type u_2} [Repr α] [Repr β] :
                        Repr (α β)
                        class ReprTuple (α : Type u) :
                        Instances
                          @[implicit_reducible]
                          instance instReprTupleOfRepr {α : Type u_1} [Repr α] :
                          def Prod.reprTuple {α : Type u_1} {β : Type u_2} [Repr α] [ReprTuple β] :
                          Instances For
                            @[implicit_reducible]
                            instance instReprTupleProdOfRepr {α : Type u_1} {β : Type u_2} [Repr α] [ReprTuple β] :
                            ReprTuple (α × β)
                            def Prod.repr {α : Type u_1} {β : Type u_2} [Repr α] [ReprTuple β] :
                            α × βNatStd.Format
                            Instances For
                              @[implicit_reducible]
                              instance instReprProdOfReprTuple {α : Type u_1} {β : Type u_2} [Repr α] [ReprTuple β] :
                              Repr (α × β)
                              def Sigma.repr {α : Type u_1} {β : αType v} [Repr α] [(x : α) → Repr (β x)] :
                              Sigma βNatStd.Format
                              Instances For
                                @[implicit_reducible]
                                instance instReprSigma {α : Type u_1} {β : αType v} [Repr α] [(x : α) → Repr (β x)] :
                                Repr (Sigma β)
                                @[implicit_reducible]
                                instance instReprSubtype {α : Type u_1} {p : αProp} [Repr α] :

                                Returns a single digit representation of n, which is assumed to be in a base less than or equal to 16. Returns '*' if n > 15.

                                Examples:

                                Instances For
                                  def Nat.toDigitsCore (base : Nat) :
                                  NatNatList CharList Char
                                  Instances For
                                    def Nat.toDigits (base n : Nat) :

                                    Returns the decimal representation of a natural number as a list of digit characters in the given base. If the base is greater than 16 then '*' is returned for digits greater than 0xf.

                                    Examples:

                                    Instances For
                                      @[extern lean_string_of_usize]

                                      Converts a word-sized unsigned integer into a decimal string.

                                      This function is overridden at runtime with an efficient implementation.

                                      Examples:

                                      Instances For
                                        Instances For
                                          @[implemented_by Nat.reprFast]
                                          def Nat.repr (n : Nat) :

                                          Converts a natural number to its decimal string representation.

                                          Instances For

                                            Converts a natural number less than 10 to the corresponding Unicode superscript digit character. Returns '*' for other numbers.

                                            Examples:

                                            Instances For

                                              Converts a natural number to the list of Unicode superscript digit characters that corresponds to its decimal representation.

                                              Examples:

                                              Instances For

                                                Converts a natural number to a string that contains the its decimal representation as Unicode superscript digit characters.

                                                Examples:

                                                Instances For

                                                  Converts a natural number less than 10 to the corresponding Unicode subscript digit character. Returns '*' for other numbers.

                                                  Examples:

                                                  Instances For

                                                    Converts a natural number to the list of Unicode subscript digit characters that corresponds to its decimal representation.

                                                    Examples:

                                                    Instances For

                                                      Converts a natural number to a string that contains the its decimal representation as Unicode subscript digit characters.

                                                      Examples:

                                                      Instances For
                                                        @[implicit_reducible]
                                                        instance instReprNat :

                                                        Returns the decimal string representation of an integer.

                                                        Instances For
                                                          @[implicit_reducible]
                                                          instance instReprInt :
                                                          Instances For
                                                            def Char.quoteCore (c : Char) (inString : Bool := false) :
                                                            Instances For

                                                              Quotes the character to its representation as a character literal, surrounded by single quotes and escaped as necessary.

                                                              Examples:

                                                              Instances For
                                                                @[implicit_reducible]
                                                                def Char.repr (c : Char) :
                                                                Instances For

                                                                  Converts a string to its corresponding Lean string literal syntax. Double quotes are added to each end, and internal characters are escaped as needed.

                                                                  Examples:

                                                                  Instances For
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    instance instReprFin (n : Nat) :
                                                                    Repr (Fin n)
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    @[implicit_reducible]
                                                                    def List.repr {α : Type u_1} [Repr α] (a : List α) (n : Nat) :
                                                                    Instances For
                                                                      @[implicit_reducible]
                                                                      instance instReprList {α : Type u_1} [Repr α] :
                                                                      Repr (List α)
                                                                      def List.repr' {α : Type u_1} [Repr α] [ReprAtom α] (a : List α) (n : Nat) :
                                                                      Instances For
                                                                        @[implicit_reducible]
                                                                        instance instReprListOfReprAtom {α : Type u_1} [Repr α] [ReprAtom α] :
                                                                        Repr (List α)
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]
                                                                        @[implicit_reducible]