Skip to content

Commit

Permalink
Distinguish between creation and call site and include both if approp…
Browse files Browse the repository at this point in the history
…riate
  • Loading branch information
arybczak committed Sep 12, 2024
1 parent f2bdfc3 commit d97c9db
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions effectful-core/src/Effectful/Internal/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ()
Expand Down

0 comments on commit d97c9db

Please sign in to comment.