From 138b7a5775251c330ade870a0b8d1f5c4659e669 Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Tue, 22 Jun 2021 15:29:15 -0400 Subject: There's no "errorWithCallStack", just use "error". There's no `errorWithCallStack`, only `errorWithStackTrace`, but the latter is now deprecated, since `error` now defaults to returning a stack strace. So rather than change this to the intended deprecated function we replace `errorWithCallStack` with `error` instead. --- docs/users_guide/exts/callstack.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/users_guide/exts/callstack.rst b/docs/users_guide/exts/callstack.rst index 59d17cae9c..579a003148 100644 --- a/docs/users_guide/exts/callstack.rst +++ b/docs/users_guide/exts/callstack.rst @@ -72,7 +72,7 @@ The ``CallStack`` will only extend as far as the types allow it, for example :: myHead :: HasCallStack => [a] -> a - myHead [] = errorWithCallStack "empty" + myHead [] = error "empty" myHead (x:xs) = x bad :: Int @@ -83,12 +83,11 @@ example :: ghci> bad *** Exception: empty CallStack (from HasCallStack): - errorWithCallStack, called at Bad.hs:8:15 in main:Bad + error, called at Bad.hs:8:15 in main:Bad myHead, called at Bad.hs:12:7 in main:Bad -includes the call-site of ``errorWithCallStack`` in ``myHead``, and of -``myHead`` in ``bad``, but not the call-site of ``bad`` at the GHCi -prompt. +includes the call-site of ``error`` in ``myHead``, and of ``myHead`` in +``bad``, but not the call-site of ``bad`` at the GHCi prompt. GHC solves ``HasCallStack`` constraints in two steps: @@ -114,12 +113,12 @@ package, module, and file name, as well as the line and column numbers. allows users to freeze the current ``CallStack``, preventing any future push operations from having an effect. This can be used by library authors to prevent ``CallStack``\s from exposing unnecessary implementation -details. Consider the ``myHead`` example above, the ``errorWithCallStack`` line in -the printed stack is not particularly enlightening, so we might choose -to suppress it by freezing the ``CallStack`` that we pass to ``errorWithCallStack``. :: +details. Consider the ``myHead`` example above, the ``error`` line in the +printed stack is not particularly enlightening, so we might choose to suppress +it by freezing the ``CallStack`` that we pass to ``error``. :: myHead :: HasCallStack => [a] -> a - myHead [] = withFrozenCallStack (errorWithCallStack "empty") + myHead [] = withFrozenCallStack (error "empty") myHead (x:xs) = x .. code-block:: none -- cgit v1.2.1