Documentation

Std.Tactic.CoeExt

The @[coe] attribute, used to delaborate coercion functions as #

When writing a coercion, if the pattern

@[coe]
def A.toB (a : A) : B := sorry

instance : Coe A B where coe := A.toB

is used, then A.toB a will be pretty-printed as ↑a.

This file also provides ⇑f and ↥t notation, which are syntax for Lean.Meta.coerceToFunction? and Lean.Meta.coerceToSort? respectively.

⇑ t coerces t to a function.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    ↥ t coerces t to a type.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The different types of coercions that are supported by the coe attribute.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.

        Information associated to a coercion function to enable sensible delaboration.

        • numArgs : Nat

          The number of arguments to the coercion function

        • coercee : Nat

          The argument index that represents the value being coerced

        • The type of coercion

        Instances For
          Equations
          Equations
          • One or more equations did not get rendered due to their size.

          The environment extension for tracking coercion functions for delaboration

          Lookup the coercion information for a given function

          Equations
          Instances For

            This delaborator tries to elide functions which are known coercions. For example, Int.ofNat is a coercion, so instead of printing ofNat n we just print ↑n, and when re-parsing this we can (usually) recover the specific coercion being used.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Add a coercion delaborator for the given function.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Add name to the coercion extension and add a coercion delaborator for the function.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  The @[coe] attribute on a function (which should also appear in a instance : Coe A B := ⟨myFn⟩ declaration) allows the delaborator to show applications of this function as when printing expressions.

                  Equations
                  Instances For