Commit 380b25ea authored by Committed by Ben GamariBrowse files
Allow CallStacks to be frozen
This introduces "freezing," an operation which prevents further locations from being appended to a CallStack. Library authors may want to prevent CallStacks from exposing implementation details, as a matter of hygiene. For example, in ``` head  = error "head: empty list" ghci> head  *** Exception: head: empty list CallStack (from implicit params): error, called at ... ``` including the call-site of `error` in `head` is not strictly necessary as the error message already specifies clearly where the error came from. So we add a function `freezeCallStack` that wraps an existing CallStack, preventing further call-sites from being pushed onto it. In other words, ``` pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack ``` Now we can define `head` to not produce a CallStack at all ``` head  = let ?callStack = freezeCallStack emptyCallStack in error "head: empty list" ghci> head  *** Exception: head: empty list CallStack (from implici...