Skip to content
Snippets Groups Projects
Commit 138b7a57 authored by vdukhovni's avatar vdukhovni Committed by Marge Bot
Browse files

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.
parent 171413c6
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment