module Plutarch.Internal.PrettyStack (prettyStack) where import Data.Text (Text, pack) import GHC.Stack (CallStack, SrcLoc (srcLocFile, srcLocStartLine), getCallStack) prettyStack :: Text -> CallStack -> Text prettyStack :: Text -> CallStack -> Text prettyStack Text prefix CallStack cs = case CallStack -> [(String, SrcLoc)] getCallStack CallStack cs of ((String _, SrcLoc loc) : [(String, SrcLoc)] _) -> let loc' :: Text loc' = String -> Text pack SrcLoc loc.srcLocFile Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text ":" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> String -> Text pack (Int -> String forall a. Show a => a -> String show SrcLoc loc.srcLocStartLine) in Text prefix Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text "[" Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text loc' Text -> Text -> Text forall a. Semigroup a => a -> a -> a <> Text "]" [(String, SrcLoc)] _ -> Text "<missing call stack>"