Hi, 

I am struggling to debug a loop (some nontermination behaviour) of a huge program. Normally, I use `stack build` to generate it. I have tried to use `trace` at lots of places in the code, recompile and see what happens. However, it isn't always clear in what order the trace statements are fired, because of the lazy evaluation of Haskell. 

So I tried another approach. I have a function

fatal :: HasCallStack => Text -> a
fatal msg =
  exitWith . Fatal . T.lines $
    ( msg <> "\n"
        <> (utf8BuilderToText . displayCallStackFull $ callStack)
    )
 
displayCallStackFull :: CallStack -> Utf8Builder
displayCallStackFull cs =
  case reverse $ getCallStack cs of
    [] -> "<no call stack found>"
    xs -> mconcat $ fmap showCall xs
  where
    showCall :: (String, SrcLoc) -> Utf8Builder
    showCall (desc, loc) =
      let file = srcLocFile loc
       in "\n"
            <> fromString file
            <> ":"
            <> displayShow (srcLocStartLine loc)
            <> ":"
            <> displayShow (srcLocStartCol loc)
            <> " "
            <> fromString desc


(The function to show the stack was inspired from https://hackage.haskell.org/package/rio-0.1.22.0/docs/RIO.html#v:displayCallStack).

I would expect that at any place where I force a call to `fatal`, I would get the full stacktrace. Unfortunately, I only get the place where the call to fatal is in the code. 

I have been looking at the documentation of both stack and ghc, but I don't understand how to compile my code in a way that the full stacktrace is shown. 

Until now the best guess I have is 

stack install --profile --no-strip && ampersand -- check testing/Sentinel/Tests/ShouldSucceed/OnlyValidation/Issue280.adl

The ultimate goal is to get rid of this ugly bug regarding the loop. Any help/suggestions is really appreciated!

Thanks for reading.
Han Joosten