If we get a <<loop>>
, it means that Haskell had managed to detect an infinite loop. Is there a way to get ghc to tell us where this loop happened? It seems that Haskell should have this information somewhere.
Compile your app with -prof
and -fprof-auto
(if you're using Cabal, use --enable-executable-profiling
and --ghc-options=-fprof-auto
) and then run it with +RTS -xc
. It'll print a stack trace when errors happen. This should help you narrow your scope.
Example:
➜ haskell cat loop.hs myFun :: Int myFun = let g = g + 1 in g + 10 main = print myFun ➜ haskell ghc loop.hs -prof -fprof-auto [1 of 1] Compiling Main ( loop.hs, loop.o ) Linking loop ... ➜ haskell ./loop +RTS -xc *** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: Main.myFun.g, called from Main.myFun, called from Main.CAF *** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: Main.myFun.g, called from Main.myFun, called from Main.CAF loop: <<loop>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With