haskell-debugger-0.5.0.0: haskell-debugger/GHC/Debugger/Utils.hs
{-# LANGUAGE CPP, NamedFieldPuns, TupleSections, LambdaCase,
DuplicateRecordFields, RecordWildCards, TupleSections, ViewPatterns,
TypeApplications, ScopedTypeVariables, BangPatterns #-}
module GHC.Debugger.Utils where
import GHC
import GHC.Data.FastString
import GHC.Driver.DynFlags as GHC
import GHC.Driver.Ppr as GHC
import GHC.Utils.Outputable as GHC
import GHC.Debugger.Monad
import GHC.Debugger.Interface.Messages
--------------------------------------------------------------------------------
-- * GHC Utilities
--------------------------------------------------------------------------------
-- | Convert a GHC's src span into an interface one
realSrcSpanToSourceSpan :: RealSrcSpan -> SourceSpan
realSrcSpanToSourceSpan ss = SourceSpan
{ file = unpackFS $ srcSpanFile ss
, startLine = srcSpanStartLine ss
, startCol = srcSpanStartCol ss
, endLine = srcSpanEndLine ss
, endCol = srcSpanEndCol ss
}
-- | Display an Outputable value as a String
display :: Outputable a => a -> Debugger String
display x = do
dflags <- getDynFlags
return $ showSDoc dflags (ppr x)
{-# INLINE display #-}