Module docstring
{"# Debugging helper functions "}
{"# Debugging helper functions "}
dbgTrace
definition
{α : Type u} (s : String) (f : Unit → α) : α
dbgTraceVal
definition
{α : Type u} [ToString α] (a : α) : α
def dbgTraceVal {α : Type u} [ToString α] (a : α) : α :=
dbgTrace (toString a) (fun _ => a)
dbgTraceIfShared
definition
{α : Type u} (s : String) (a : α) : α
/-- Display the given message if `a` is shared, that is, RC(a) > 1 -/
@[never_extract, extern "lean_dbg_trace_if_shared"]
def dbgTraceIfShared {α : Type u} (s : String) (a : α) : α := a
dbgStackTrace
definition
{α : Type u} (f : Unit → α) : α
/-- Print stack trace to stderr before evaluating given closure. Currently supported on Linux only. -/
@[never_extract, extern "lean_dbg_stack_trace"]
def dbgStackTrace {α : Type u} (f : Unit → α) : α := f ()
dbgSleep
definition
{α : Type u} (ms : UInt32) (f : Unit → α) : α
panicWithPos
definition
{α : Sort u} [Inhabited α] (modName : String) (line col : Nat) (msg : String) : α
panicWithPosWithDecl
definition
{α : Sort u} [Inhabited α] (modName : String) (declName : String) (line col : Nat) (msg : String) : α
ptrAddrUnsafe
opaque
{α : Type u} (a : @& α) : USize
/--
Returns the address at which an object is allocated.
This function is unsafe because it can distinguish between definitionally equal values.
-/
@[extern "lean_ptr_addr"]
unsafe opaque ptrAddrUnsafe {α : Type u} (a : @& α) : USize
isExclusiveUnsafe
opaque
{α : Type u} (a : @& α) : Bool
/--
Returns `true` if `a` is an exclusive object.
An object is exclusive if it is single-threaded and its reference counter is 1. This function is
unsafe because it can distinguish between definitionally equal values.
-/
@[extern "lean_is_exclusive_obj"]
unsafe opaque isExclusiveUnsafe {α : Type u} (a : @& α) : Bool
withPtrAddrUnsafe
definition
{α : Type u} {β : Type v} (a : α) (k : USize → β) (h : ∀ u₁ u₂, k u₁ = k u₂) : β
@[inline] unsafe def withPtrAddrUnsafe {α : Type u} {β : Type v} (a : α) (k : USize → β) (h : ∀ u₁ u₂, k u₁ = k u₂) : β :=
k (ptrAddrUnsafe a)
ptrEq
definition
(a b : α) : Bool
/--
Compares two objects for pointer equality.
Two objects are pointer-equal if, at runtime, they are allocated at exactly the same address. This
function is unsafe because it can distinguish between definitionally equal values.
-/
@[inline] unsafe def ptrEq (a b : α) : Bool := ptrAddrUnsafe a == ptrAddrUnsafe b
withPtrEqUnsafe
definition
{α : Type u} (a b : α) (k : Unit → Bool) (h : a = b → k () = true) : Bool
@[inline] unsafe def withPtrEqUnsafe {α : Type u} (a b : α) (k : Unit → Bool) (h : a = b → k () = true) : Bool :=
if ptrEq a b then true else k ()
withPtrEq
definition
{α : Type u} (a b : α) (k : Unit → Bool) (h : a = b → k () = true) : Bool
withPtrEqDecEq
definition
{α : Type u} (a b : α) (k : Unit → Decidable (a = b)) : Decidable (a = b)
/-- `withPtrEq` for `DecidableEq` -/
@[inline] def withPtrEqDecEq {α : Type u} (a b : α) (k : Unit → Decidable (a = b)) : Decidable (a = b) :=
let b := withPtrEq a b (fun _ => toBoolUsing (k ())) (toBoolUsing_eq_true (k ()));
match h:b with
| true => isTrue (ofBoolUsing_eq_true h)
| false => isFalse (ofBoolUsing_eq_false h)
withPtrAddr
definition
{α : Type u} {β : Type v} (a : α) (k : USize → β) (h : ∀ u₁ u₂, k u₁ = k u₂) : β
@[implemented_by withPtrAddrUnsafe]
def withPtrAddr {α : Type u} {β : Type v} (a : α) (k : USize → β) (h : ∀ u₁ u₂, k u₁ = k u₂) : β := k 0