# Documentation

Lean.LazyInitExtension

structure Lean.LazyInitExtension (m : ) (α : Type) :
• ext :
• fn : m α
Instances For
instance Lean.instInhabitedLazyInitExtension {m : } {α : Type} [inst : ] [inst : ] :
Equations
• Lean.instInhabitedLazyInitExtension = { default := { ext := default, fn := pure default } }
def Lean.registerLazyInitExtension {m : } {α : Type} (fn : m α) :
IO ()

Register an environment extension for storing the result of fn. We initialize the extension with none, and fn is executed the first time LazyInit.get is executed.

This kind of extension is useful for avoiding work duplication in scenarios where a thunk cannot be used because the computation depends on state from the m monad. For example, we may want to "cache" a collection of theorems as a SimpLemmas object.

Equations
• = do let ext ← pure { ext := ext, fn := fn }
def Lean.LazyInitExtension.get {m : } {α : Type} [inst : ] [inst : ] (init : ) :
m α
Equations
• One or more equations did not get rendered due to their size.