Wolfgang Jeltsch pushed to branch wip/jeltsch/ghc-9-14-building-base at Glasgow Haskell Compiler / GHC Commits: 952f9965 by Wolfgang Jeltsch at 2026-08-12T16:33:25+03:00 Move the definition of `withEmptyCallStack` into `base` - - - - - 2 changed files: - libraries/base/src/GHC/Stack.hs - libraries/ghc-internal/src/GHC/Internal/Stack.hs Changes: ===================================== libraries/base/src/GHC/Stack.hs ===================================== @@ -1,5 +1,8 @@ {-# LANGUAGE Safe #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ImplicitParams #-} + -- | -- -- Module : GHC.Stack @@ -51,3 +54,20 @@ module GHC.Stack ) where import GHC.Internal.Stack + +-- | Explicitly bring the empty call stack into scope. +-- +-- Mostly useful for silencing warnings generated by @-Wdefaulted-callstack@ in +-- places such as: +-- +-- - The body of a class method in an instance of an externally defined type +-- class whose type signature doesn't contain a 'HasCallStack' constraint. +-- +-- - The body of the @main@ function. +-- +-- @since 4.24.0.0 +withEmptyCallStack :: (HasCallStack => a) -> a +withEmptyCallStack do_this = + -- See Note [Warn about defaulted CallStacks] + let ?callStack = emptyCallStack + in do_this ===================================== libraries/ghc-internal/src/GHC/Internal/Stack.hs ===================================== @@ -29,7 +29,7 @@ module GHC.Internal.Stack ( -- * HasCallStack call stacks CallStack, HasCallStack, callStack, emptyCallStack, freezeCallStack, fromCallSiteList, getCallStack, popCallStack, - pushCallStack, withFrozenCallStack, withEmptyCallStack, + pushCallStack, withFrozenCallStack, prettyCallStackLines, prettyCallStack, -- * Source locations @@ -105,23 +105,6 @@ withFrozenCallStack do_this = let ?callStack = freezeCallStack (popCallStack callStack) in do_this --- | Explicitly bring the empty call stack into scope. --- --- Mostly useful for silencing warnings generated by @-Wdefaulted-callstack@ in --- places such as: --- --- - The body of a class method in an instance of an externally defined type --- class whose type signature doesn't contain a 'HasCallStack' constraint. --- --- - The body of the @main@ function. --- --- @since 4.24.0.0 -withEmptyCallStack :: (HasCallStack => a) -> a -withEmptyCallStack do_this = - -- See Note [Warn about defaulted CallStacks] - let ?callStack = emptyCallStack - in do_this - -- prettySrcLoc and prettyCallStack are defined here to avoid hs-boot -- files. See Note [Definition of CallStack] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/952f9965916aa952d7d129f0a0b108fe... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/952f9965916aa952d7d129f0a0b108fe... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Wolfgang Jeltsch (@jeltsch)