module GHC.ExecutionStack (
Location (..)
, SrcLoc (..)
, getStackTrace
, showStackTrace
) where
import Control.Monad (join)
import GHC.ExecutionStack.Internal
getStackTrace :: IO (Maybe [Location])
getStackTrace :: IO (Maybe [Location])
getStackTrace = (Maybe (Maybe [Location]) -> Maybe [Location]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Maybe (Maybe [Location]) -> Maybe [Location])
-> (Maybe StackTrace -> Maybe (Maybe [Location]))
-> Maybe StackTrace
-> Maybe [Location]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StackTrace -> Maybe [Location])
-> Maybe StackTrace -> Maybe (Maybe [Location])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StackTrace -> Maybe [Location]
stackFrames) (Maybe StackTrace -> Maybe [Location])
-> IO (Maybe StackTrace) -> IO (Maybe [Location])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` IO (Maybe StackTrace)
collectStackTrace
showStackTrace :: IO (Maybe String)
showStackTrace :: IO (Maybe String)
showStackTrace = ([Location] -> String) -> Maybe [Location] -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\st :: [Location]
st -> [Location] -> ShowS
showStackFrames [Location]
st "") (Maybe [Location] -> Maybe String)
-> IO (Maybe [Location]) -> IO (Maybe String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` IO (Maybe [Location])
getStackTrace