module Language.SequentCore.Util (
Maybes.orElse, consMaybe, pprTraceShort
) where
import DynFlags
import Maybes
import Outputable
import StaticFlags
infixr 5 `consMaybe`
consMaybe :: Maybe a -> [a] -> [a]
Just x `consMaybe` xs = x : xs
Nothing `consMaybe` xs = xs
pprTraceShort :: String -> SDoc -> a -> a
pprTraceShort str doc x
| opt_NoDebugOutput = x
| otherwise = pprAndThen unsafeGlobalDynFlags trace str doc x
pprAndThen :: DynFlags -> (String -> a) -> String -> SDoc -> a
pprAndThen dflags cont heading pretty_msg
= cont (showSDoc dflags doc)
where
doc = sep [text heading, nest 4 pretty_msg]