import Control.Exception import GHC.Stack headWithoutCS :: [a] -> a headWithoutCS = head headWithCS :: HasCallStack => [a] -> a headWithCS = head nil :: [()] nil = [] main :: IO () main = do putStrLn "Doesn't include 'headWithoutCS' in the stack:" evaluate (headWithoutCS nil) `catch` \(SomeException e) -> print e putStrLn "" putStrLn "Does include 'headWithCS' in the stack:" evaluate (headWithCS nil) `catch` \(SomeException e) -> print e