Debugging helper functions #
Equations
- dbgTraceVal a = dbgTrace (toString a) fun (x : Unit) => a
Instances For
Print stack trace to stderr before evaluating given closure. Currently supported on Linux only.
Equations
- dbgStackTrace f = f ()
Instances For
Equations
- panicWithPos modName line col msg = panic (mkPanicMessage modName line col msg)
Instances For
Equations
- panicWithPosWithDecl modName declName line col msg = panic (mkPanicMessageWithDecl modName declName line col msg)
Instances For
Returns the address at which an object is allocated.
This function is unsafe because it can distinguish between definitionally equal values.
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.
Equations
- withPtrAddrUnsafe a k h = k (ptrAddrUnsafe a)
Instances For
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.
Equations
- ptrEq a b = (ptrAddrUnsafe a == ptrAddrUnsafe b)
Instances For
Compares two lists of objects for element-wise pointer equality. Returns true if both lists are
the same length and the objects at the corresponding indices of each list are pointer-equal.
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.
Equations
Instances For
Returns true if a and b are represented by the same pointer at runtime, or k () otherwise.
If k is a function that performs an equality check on a and b, then this operation can be
used to short-circuit the equality check for pointer-equal input.
This function is unsafe because its result is not equal to k () if α includes computationally
irrelevant data like types. Consider the example α := Prop, a := True, b := False,
k := fun _ => false. In this case, a = b → k () = true is true, but a and b have the same
runtime representation of an erased type, so ptrEq a b is true and this function returns true,
even though k () is false.
withPtrEq is a safe version of this function, for which the compiler checks that α does not
include such data.
Instances For
Returns k (), but skips evaluating k () and returns true if a and b are represented by the
same pointer at runtime.
If k is a function that performs an equality check on a and b, then this operation can be
used to short-circuit the equality check for pointer-equal input.
This is only correct if pointer-equal values of α are equal. This is not the case if values of α
can contain types or type formers, because these are erased at runtime. For example, True and
False have the same runtime representation, but withPtrEq True False (fun _ => false) _ must
return false. Therefore, the compiler refuses to compile a definition that uses withPtrEq unless
it can check that values of α cannot contain types or type formers. In particular, withPtrEq
cannot be used polymorphically: it can be used at types such as List Nat or Fin n, but not at
List β if β is a type variable.
Use withPtrEqUnsafe to bypass this check.
Instances For
Build a DecidableEq instance that short-circuits using a pointer equality check where possible.
Usually, withPtrEq is passed as the first argument, as in
withPtrEqDecEq withPtrEq (fun _ _ _ _ => rfl) a b k. Since withPtrEqDecEq is polymorphic, it
cannot use withPtrEq directly; see the docstring of withPtrEq.
Equations
- withPtrEqDecEq withPtrEq hw a b k = { decide := withPtrEq a b (fun (x : Unit) => toBoolUsing (k ())) ⋯, reflects_decide := ⋯ }
Instances For
Equations
- withPtrAddr a k h = k 0