Skip to content

Instantly share code, notes, and snippets.

@fghibellini
Created November 8, 2019 16:30
Show Gist options
  • Save fghibellini/0da00bdfb95b48d87485cba3e5b95c11 to your computer and use it in GitHub Desktop.
Save fghibellini/0da00bdfb95b48d87485cba3e5b95c11 to your computer and use it in GitHub Desktop.
ghc stacktraces
{-# LANGUAGE RankNTypes #-}
import Control.Monad (forM_)
import GHC.Stack
httpCall :: HasCallStack => IO ()
httpCall = do
putStrLn $ prettyCallStack $ callStack
print "http resolved"
retry :: HasCallStack => (HasCallStack => IO()) -> IO ()
retry op = do
forM_ [1] $ \i -> do
op
main = retry httpCall
GHCi, version 8.6.5
CallStack (from HasCallStack):
httpCall, called at main.hs:16:14 in main:Main
op, called at main.hs:14:5 in main:Main
retry, called at main.hs:16:8 in main:Main
"http resolved"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment