From d97c9dbd519b818acb1887fa937cbec77cfe36bc Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 12 Sep 2024 17:28:25 +0200 Subject: [PATCH] Distinguish between creation and call site and include both if appropriate --- effectful-core/src/Effectful/Internal/Env.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/effectful-core/src/Effectful/Internal/Env.hs b/effectful-core/src/Effectful/Internal/Env.hs index adbe504..8bc824d 100644 --- a/effectful-core/src/Effectful/Internal/Env.hs +++ b/effectful-core/src/Effectful/Internal/Env.hs @@ -49,7 +49,7 @@ import Control.Monad.Primitive import Data.IORef.Strict import Data.Primitive.PrimArray import Data.Primitive.SmallArray -import GHC.Stack (HasCallStack) +import GHC.Stack import Effectful.Internal.Effect import Effectful.Internal.Utils @@ -453,10 +453,20 @@ noVersion :: Int noVersion = 0 undefinedEffect :: HasCallStack => AnyEffect -undefinedEffect = toAnyEffect $ error "undefined effect" - -undefinedRelinker :: AnyRelinker -undefinedRelinker = toAnyRelinker $ Relinker $ \_ _ -> error "undefined relinker" +undefinedEffect = toAnyEffect . errorWithoutStackTrace $ unlines + [ "Undefined effect" + , "Created at: " ++ prettyCallStack callStack + ] + +undefinedRelinker :: HasCallStack => AnyRelinker +undefinedRelinker = toAnyRelinker $ Relinker $ \_ _ -> do + errorWithoutStackTrace $ unlines + [ "Undefined relinker" + , "Created at: " ++ prettyCallStack creationCallStack + , "Called at: " ++ prettyCallStack callStack + ] + where + creationCallStack = callStack -- | A strict version of 'writeSmallArray'. writeSmallArray' :: SmallMutableArray RealWorld a -> Int -> a -> IO ()