File: .lake/packages/lean4/src/lean/Lean/Meta/CoeAttr.lean

full_name: Lean.Meta.CoeFnType.coeSort
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Lean.Meta.CoeFnType

full_name: Lean.Meta.instReprCoeFnType
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Repr Lean.Meta.CoeFnType

full_name: Lean.Meta.CoeFnType
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Type

full_name: Lean.Meta.instDecidableEqCoeFnType
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: DecidableEq Lean.Meta.CoeFnType

full_name: Lean.Meta.CoeFnType.coeFun
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Lean.Meta.CoeFnType

full_name: Lean.Meta.instInhabitedCoeFnType
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Inhabited Lean.Meta.CoeFnType

full_name: Lean.Meta.CoeFnType.coe
code: /-- The different types of coercions that are supported by the `coe` attribute. -/
inductive CoeFnType
  /-- The basic coercion `↑x`, see `CoeT.coe` -/
  | coe
  /-- The coercion to a function type, see `CoeFun.coe` -/
  | coeFun
  /-- The coercion to a type, see `CoeSort.coe` -/
  | coeSort
  deriving Inhabited, Repr, DecidableEq
goal: Lean.Meta.CoeFnType

full_name: Lean.Meta.instToExprCoeFnType
code: instance : ToExpr CoeFnType 
goal: Lean.ToExpr Lean.Meta.CoeFnType

full_name: Lean.Meta.CoeFnInfo
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Type

full_name: Lean.Meta.CoeFnInfo.type
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Lean.Meta.CoeFnType

full_name: Lean.Meta.instReprCoeFnInfo
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Repr Lean.Meta.CoeFnInfo

full_name: Lean.Meta.CoeFnInfo.numArgs
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Nat

full_name: Lean.Meta.instInhabitedCoeFnInfo
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Inhabited Lean.Meta.CoeFnInfo

full_name: Lean.Meta.CoeFnInfo.coercee
code: /-- Information associated to a coercion function to enable sensible delaboration. -/
structure CoeFnInfo where
  /-- The number of arguments to the coercion function -/
  numArgs : Nat
  /-- The argument index that represents the value being coerced -/
  coercee : Nat
  /-- The type of coercion -/
  type : CoeFnType
  deriving Inhabited, Repr
goal: Nat

full_name: Lean.Meta.instToExprCoeFnInfo
code: instance : ToExpr CoeFnInfo 
goal: Lean.ToExpr Lean.Meta.CoeFnInfo

full_name: Lean.Meta.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.CoeAttr._hyg.445
code: /-- The environment extension for tracking coercion functions for delaboration -/
-- TODO: does it need to be a scoped extension
initialize coeExt : SimpleScopedEnvExtension (Name × CoeFnInfo) (NameMap CoeFnInfo) ←
  registerSimpleScopedEnvExtension {
    addEntry := fun st (n, i) => st.insert n i
    initial := {}
  }
goal: IO (Lean.SimpleScopedEnvExtension (Lean.Name × Lean.Meta.CoeFnInfo) (Lean.NameMap Lean.Meta.CoeFnInfo))

full_name: Lean.Meta.coeExt
code: /-- The environment extension for tracking coercion functions for delaboration -/
-- TODO: does it need to be a scoped extension
initialize coeExt : SimpleScopedEnvExtension (Name × CoeFnInfo) (NameMap CoeFnInfo) ←
  registerSimpleScopedEnvExtension {
    addEntry := fun st (n, i) => st.insert n i
    initial := {}
  }
goal: Lean.SimpleScopedEnvExtension (Lean.Name × Lean.Meta.CoeFnInfo) (Lean.NameMap Lean.Meta.CoeFnInfo)

full_name: Lean.Meta.getCoeFnInfo?
code: /-- Lookup the coercion information for a given function -/
def getCoeFnInfo? (fn : Name) : CoreM (Option CoeFnInfo) 
goal: Lean.CoreM (Option Lean.Meta.CoeFnInfo)

full_name: Lean.Meta.registerCoercion
code: /-- Add `name` to the coercion extension and add a coercion delaborator for the function. -/
def registerCoercion (name : Name) (info : Option CoeFnInfo := none) : MetaM Unit 
goal: Lean.MetaM Unit

full_name: Lean.Meta.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.CoeAttr._hyg.776
code: builtin_initialize registerBuiltinAttribute {
  name := `coe
  descr := "Adds a definition as a coercion"
  add := fun decl _stx kind => MetaM.run' do
    unless kind == .global do
      throwError "cannot add local or scoped coe attribute"
    registerCoercion decl
}
goal: IO Unit